1 /* 2 * Copyright (C) 2007 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.common.collect; 18 19 import com.google.common.annotations.GwtCompatible; 20 21 import java.util.Comparator; 22 import java.util.SortedSet; 23 24 /** 25 * A sorted set which forwards all its method calls to another sorted set. 26 * Subclasses should override one or more methods to modify the behavior of the 27 * backing sorted set as desired per the <a 28 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>. 29 * 30 * @see ForwardingObject 31 * @author Mike Bostock 32 * @since 2010.01.04 <b>stable</b> (imported from Google Collections Library) 33 */ 34 @GwtCompatible 35 public abstract class ForwardingSortedSet<E> extends ForwardingSet<E> 36 implements SortedSet<E> { 37 38 @Override protected abstract SortedSet<E> delegate(); 39 40 public Comparator<? super E> comparator() { 41 return delegate().comparator(); 42 } 43 44 public E first() { 45 return delegate().first(); 46 } 47 48 public SortedSet<E> headSet(E toElement) { 49 return delegate().headSet(toElement); 50 } 51 52 public E last() { 53 return delegate().last(); 54 } 55 56 public SortedSet<E> subSet(E fromElement, E toElement) { 57 return delegate().subSet(fromElement, toElement); 58 } 59 60 public SortedSet<E> tailSet(E fromElement) { 61 return delegate().tailSet(fromElement); 62 } 63 } 64