001 /* 002 * Copyright (C) 2007 Google Inc. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 package com.google.common.collect; 018 019 import com.google.common.annotations.GwtCompatible; 020 021 import java.util.Comparator; 022 import java.util.SortedSet; 023 024 /** 025 * A sorted set which forwards all its method calls to another sorted set. 026 * Subclasses should override one or more methods to modify the behavior of the 027 * backing sorted set as desired per the <a 028 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>. 029 * 030 * @author Mike Bostock 031 * @since 2 (imported from Google Collections Library) 032 */ 033 @GwtCompatible 034 public abstract class ForwardingSortedSet<E> extends ForwardingSet<E> 035 implements SortedSet<E> { 036 037 /** Constructor for use by subclasses. */ 038 protected ForwardingSortedSet() {} 039 040 @Override protected abstract SortedSet<E> delegate(); 041 042 public Comparator<? super E> comparator() { 043 return delegate().comparator(); 044 } 045 046 public E first() { 047 return delegate().first(); 048 } 049 050 public SortedSet<E> headSet(E toElement) { 051 return delegate().headSet(toElement); 052 } 053 054 public E last() { 055 return delegate().last(); 056 } 057 058 public SortedSet<E> subSet(E fromElement, E toElement) { 059 return delegate().subSet(fromElement, toElement); 060 } 061 062 public SortedSet<E> tailSet(E fromElement) { 063 return delegate().tailSet(fromElement); 064 } 065 }