View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.collections4.set;
18  
19  import java.util.Iterator;
20  import java.util.NavigableSet;
21  
22  /**
23   * Decorates another {@code NavigableSet} to provide additional behavior.
24   * <p>
25   * Methods are forwarded directly to the decorated set.
26   * </p>
27   *
28   * @param <E> the type of the elements in the navigable set
29   * @since 4.1
30   */
31  public abstract class AbstractNavigableSetDecorator<E>
32          extends AbstractSortedSetDecorator<E>
33          implements NavigableSet<E> {
34  
35      /** Serialization version */
36      private static final long serialVersionUID = 20150528L;
37  
38      /**
39       * Constructor only used in deserialization, do not use otherwise.
40       */
41      protected AbstractNavigableSetDecorator() {
42      }
43  
44      /**
45       * Constructor that wraps (not copies).
46       *
47       * @param set  the set to decorate, must not be null
48       * @throws NullPointerException if set is null
49       */
50      protected AbstractNavigableSetDecorator(final NavigableSet<E> set) {
51          super(set);
52      }
53  
54      @Override
55      public E ceiling(final E e) {
56          return decorated().ceiling(e);
57      }
58  
59      /**
60       * Gets the set being decorated.
61       *
62       * @return the decorated set
63       */
64      @Override
65      protected NavigableSet<E> decorated() {
66          return (NavigableSet<E>) super.decorated();
67      }
68  
69      @Override
70      public Iterator<E> descendingIterator() {
71          return decorated().descendingIterator();
72      }
73  
74      @Override
75      public NavigableSet<E> descendingSet() {
76          return decorated().descendingSet();
77      }
78  
79      @Override
80      public E floor(final E e) {
81          return decorated().floor(e);
82      }
83  
84      @Override
85      public NavigableSet<E> headSet(final E toElement, final boolean inclusive) {
86          return decorated().headSet(toElement, inclusive);
87      }
88  
89      @Override
90      public E higher(final E e) {
91          return decorated().higher(e);
92      }
93  
94      @Override
95      public E lower(final E e) {
96          return decorated().lower(e);
97      }
98  
99      @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 }