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 * https://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.bag; 018 019import java.util.Comparator; 020 021import org.apache.commons.collections4.SortedBag; 022import org.apache.commons.collections4.multiset.AbstractSortedMultiSetDecorator; 023 024/** 025 * Decorates another {@code SortedBag} to provide additional behavior. 026 * <p> 027 * Methods are forwarded directly to the decorated bag. 028 * </p> 029 * 030 * @param <E> The type of elements in this bag 031 * @since 3.0 032 * @deprecated Since 4.6.0, use {@link AbstractSortedMultiSetDecorator} instead. 033 */ 034@Deprecated 035public abstract class AbstractSortedBagDecorator<E> 036 extends AbstractBagDecorator<E> implements SortedBag<E> { 037 038 /** Serialization version */ 039 private static final long serialVersionUID = -8223473624050467718L; 040 041 /** 042 * Constructor only used in deserialization, do not use otherwise. 043 * 044 * @since 3.1 045 */ 046 protected AbstractSortedBagDecorator() { 047 } 048 049 /** 050 * Constructor that wraps (not copies). 051 * 052 * @param bag The bag to decorate, must not be null 053 * @throws NullPointerException if bag is null 054 */ 055 protected AbstractSortedBagDecorator(final SortedBag<E> bag) { 056 super(bag); 057 } 058 059 @Override 060 public Comparator<? super E> comparator() { 061 return decorated().comparator(); 062 } 063 064 /** 065 * Gets the bag being decorated. 066 * 067 * @return The decorated bag 068 */ 069 @Override 070 protected SortedBag<E> decorated() { 071 return (SortedBag<E>) super.decorated(); 072 } 073 074 @Override 075 public E first() { 076 return decorated().first(); 077 } 078 079 @Override 080 public E last() { 081 return decorated().last(); 082 } 083 084}