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.SortedMap; 023 024 /** 025 * A sorted map which forwards all its method calls to another sorted map. 026 * Subclasses should override one or more methods to modify the behavior of 027 * the backing sorted map 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 ForwardingSortedMap<K, V> extends ForwardingMap<K, V> 035 implements SortedMap<K, V> { 036 037 /** Constructor for use by subclasses. */ 038 protected ForwardingSortedMap() {} 039 040 @Override protected abstract SortedMap<K, V> delegate(); 041 042 public Comparator<? super K> comparator() { 043 return delegate().comparator(); 044 } 045 046 public K firstKey() { 047 return delegate().firstKey(); 048 } 049 050 public SortedMap<K, V> headMap(K toKey) { 051 return delegate().headMap(toKey); 052 } 053 054 public K lastKey() { 055 return delegate().lastKey(); 056 } 057 058 public SortedMap<K, V> subMap(K fromKey, K toKey) { 059 return delegate().subMap(fromKey, toKey); 060 } 061 062 public SortedMap<K, V> tailMap(K fromKey) { 063 return delegate().tailMap(fromKey); 064 } 065 }