001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.collections4.set; 018 019import java.util.Comparator; 020import java.util.Set; 021import java.util.SortedSet; 022 023/** 024 * Decorates another <code>SortedSet</code> to provide additional behaviour. 025 * <p> 026 * Methods are forwarded directly to the decorated set. 027 * 028 * @param <E> the type of the elements in the sorted set 029 * @since 3.0 030 */ 031public abstract class AbstractSortedSetDecorator<E> 032 extends AbstractSetDecorator<E> 033 implements SortedSet<E> { 034 035 /** Serialization version */ 036 private static final long serialVersionUID = -3462240946294214398L; 037 038 /** 039 * Constructor only used in deserialization, do not use otherwise. 040 * @since 3.1 041 */ 042 protected AbstractSortedSetDecorator() { 043 super(); 044 } 045 046 /** 047 * Constructor that wraps (not copies). 048 * 049 * @param set the set to decorate, must not be null 050 * @throws NullPointerException if set is null 051 */ 052 protected AbstractSortedSetDecorator(final Set<E> set) { 053 super(set); 054 } 055 056 /** 057 * Gets the set being decorated. 058 * 059 * @return the decorated set 060 */ 061 @Override 062 protected SortedSet<E> decorated() { 063 return (SortedSet<E>) super.decorated(); 064 } 065 066 //----------------------------------------------------------------------- 067 @Override 068 public SortedSet<E> subSet(final E fromElement, final E toElement) { 069 return decorated().subSet(fromElement, toElement); 070 } 071 072 @Override 073 public SortedSet<E> headSet(final E toElement) { 074 return decorated().headSet(toElement); 075 } 076 077 @Override 078 public SortedSet<E> tailSet(final E fromElement) { 079 return decorated().tailSet(fromElement); 080 } 081 082 @Override 083 public E first() { 084 return decorated().first(); 085 } 086 087 @Override 088 public E last() { 089 return decorated().last(); 090 } 091 092 @Override 093 public Comparator<? super E> comparator() { 094 return decorated().comparator(); 095 } 096 097}