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.Set; 22 23 import javax.annotation.Nullable; 24 25 /** 26 * A multiset which forwards all its method calls to another multiset. 27 * Subclasses should override one or more methods to modify the behavior of the 28 * backing multiset as desired per the <a 29 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>. 30 * 31 * @see ForwardingObject 32 * @author Kevin Bourrillion 33 * @since 2010.01.04 <b>stable</b> (imported from Google Collections Library) 34 */ 35 @GwtCompatible 36 public abstract class ForwardingMultiset<E> extends ForwardingCollection<E> 37 implements Multiset<E> { 38 delegate()39 @Override protected abstract Multiset<E> delegate(); 40 count(Object element)41 public int count(Object element) { 42 return delegate().count(element); 43 } 44 add(E element, int occurrences)45 public int add(E element, int occurrences) { 46 return delegate().add(element, occurrences); 47 } 48 remove(Object element, int occurrences)49 public int remove(Object element, int occurrences) { 50 return delegate().remove(element, occurrences); 51 } 52 elementSet()53 public Set<E> elementSet() { 54 return delegate().elementSet(); 55 } 56 entrySet()57 public Set<Entry<E>> entrySet() { 58 return delegate().entrySet(); 59 } 60 equals(@ullable Object object)61 @Override public boolean equals(@Nullable Object object) { 62 return object == this || delegate().equals(object); 63 } 64 hashCode()65 @Override public int hashCode() { 66 return delegate().hashCode(); 67 } 68 setCount(E element, int count)69 public int setCount(E element, int count) { 70 return delegate().setCount(element, count); 71 } 72 setCount(E element, int oldCount, int newCount)73 public boolean setCount(E element, int oldCount, int newCount) { 74 return delegate().setCount(element, oldCount, newCount); 75 } 76 } 77