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