    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 *      http://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.set;
    018
    019import java.util.Iterator;
    020import java.util.NavigableSet;
    021
    022/**
    023 * Decorates another {@code NavigableSet} to provide additional behavior.
    024 * <p>
    025 * Methods are forwarded directly to the decorated set.
    026 * </p>
    027 *
    028 * @param <E> the type of the elements in the navigable set
    029 * @since 4.1
    030 */
    031public abstract class AbstractNavigableSetDecorator<E>
    032        extends AbstractSortedSetDecorator<E>
    033        implements NavigableSet<E> {
    034
    035    /** Serialization version */
    036    private static final long serialVersionUID = 20150528L;
    037
    038    /**
    039     * Constructor only used in deserialization, do not use otherwise.
    040     */
    041    protected AbstractNavigableSetDecorator() {
    042    }
    043
    044    /**
    045     * Constructor that wraps (not copies).
    046     *
    047     * @param set  the set to decorate, must not be null
    048     * @throws NullPointerException if set is null
    049     */
    050    protected AbstractNavigableSetDecorator(final NavigableSet<E> set) {
    051        super(set);
    052    }
    053
    054    @Override
    055    public E ceiling(final E e) {
    056        return decorated().ceiling(e);
    057    }
    058
    059    /**
    060     * Gets the set being decorated.
    061     *
    062     * @return the decorated set
    063     */
    064    @Override
    065    protected NavigableSet<E> decorated() {
    066        return (NavigableSet<E>) super.decorated();
    067    }
    068
    069    @Override
    070    public Iterator<E> descendingIterator() {
    071        return decorated().descendingIterator();
    072    }
    073
    074    @Override
    075    public NavigableSet<E> descendingSet() {
    076        return decorated().descendingSet();
    077    }
    078
    079    @Override
    080    public E floor(final E e) {
    081        return decorated().floor(e);
    082    }
    083
    084    @Override
    085    public NavigableSet<E> headSet(final E toElement, final boolean inclusive) {
    086        return decorated().headSet(toElement, inclusive);
    087    }
    088
    089    @Override
    090    public E higher(final E e) {
    091        return decorated().higher(e);
    092    }
    093
    094    @Override
    095    public E lower(final E e) {
    096        return decorated().lower(e);
    097    }
    098
    099    @Override
    100    public E pollFirst() {
    101        return decorated().pollFirst();
    102    }
    103
    104    @Override
    105    public E pollLast() {
    106        return decorated().pollLast();
    107    }
    108
    109    @Override
    110    public NavigableSet<E> subSet(final E fromElement, final boolean fromInclusive, final E toElement,
    111            final boolean toInclusive) {
    112        return decorated().subSet(fromElement, fromInclusive, toElement, toInclusive);
    113    }
    114
    115    @Override
    116    public NavigableSet<E> tailSet(final E fromElement, final boolean inclusive) {
    117        return decorated().tailSet(fromElement, inclusive);
    118    }
    119
    120}