Class SealableNavigableSet<E>

java.lang.Object
com.cedarsoftware.io.util.SealableNavigableSet<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, NavigableSet<E>, Set<E>, SortedSet<E>

public class SealableNavigableSet<E> extends Object implements NavigableSet<E>
SealableNavigableSet provides a NavigableSet or NavigableSet wrapper that can be 'sealed' and 'unsealed.' When sealed, the NavigableSet is mutable, when unsealed it is immutable (read-only). The view methods iterator(), descendingIterator(), descendingSet(), subSet(), headSet(), and tailSet(), return a view that honors the Supplier's sealed state. The sealed state can be changed as often as needed.

NOTE: Please do not reformat this code as the current format makes it easy to see the overall structure.

Author:
John DeRegnaucourt
Copyright (c) Cedar Software LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

License

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
  • Constructor Details

    • SealableNavigableSet

      public SealableNavigableSet(Supplier<Boolean> sealedSupplier)
      Create a NavigableSealableSet. Since a NavigableSet is not supplied, this will use a ConcurrentSkipListSet internally. If you want to use a TreeSet for example, use the SealableNavigableSet constructor that takes a NavigableSet and pass it the instance you want it to wrap.
      Parameters:
      sealedSupplier - Supplier<Boolean> that returns 'true' to indicate sealed, 'false' for mutable.
    • SealableNavigableSet

      public SealableNavigableSet(Comparator<? super E> comparator, Supplier<Boolean> sealedSupplier)
      Create a NavigableSealableSet. Since a NavigableSet is not supplied, this will use a ConcurrentSkipListSet internally. If you want to use a TreeSet for example, use the SealableNavigableSet constructor that takes a NavigableSet and pass it the instance you want it to wrap.
      Parameters:
      comparator - Comparator A comparison function, which imposes a total ordering on some collection of objects.
      sealedSupplier - Supplier<Boolean> that returns 'true' to indicate sealed, 'false' for mutable.
    • SealableNavigableSet

      public SealableNavigableSet(Collection<? extends E> col, Supplier<Boolean> sealedSupplier)
      Create a NavigableSealableSet. Since NavigableSet is not supplied, the elements from the passed in Collection will be copied to an internal ConcurrentSkipListSet. If you want to use a TreeSet for example, use the SealableNavigableSet constructor that takes a NavigableSet and pass it the instance you want it to wrap.
      Parameters:
      col - Collection to supply initial elements. These are copied to an internal ConcurrentSkipListSet.
      sealedSupplier - Supplier<Boolean> that returns 'true' to indicate sealed, 'false' for mutable.
    • SealableNavigableSet

      public SealableNavigableSet(SortedSet<E> set, Supplier<Boolean> sealedSupplier)
      Create a NavigableSealableSet. Since NavigableSet is not supplied, the elements from the passed in SortedSet will be copied to an internal ConcurrentSkipListSet. If you want to use a TreeSet for example, use the SealableNavigableSet constructor that takes a NavigableSet and pass it the instance you want it to wrap.
      Parameters:
      set - SortedSet to supply initial elements. These are copied to an internal ConcurrentSkipListSet.
      sealedSupplier - Supplier<Boolean> that returns 'true' to indicate sealed, 'false' for mutable.
    • SealableNavigableSet

      public SealableNavigableSet(NavigableSet<E> set, Supplier<Boolean> sealedSupplier)
      Use this constructor to wrap a NavigableSet (any kind of NavigableSet) and make it a SealableNavigableSet. No duplicate of the Set is created, the original set is operated on directly if unsealed, or protected from changes if sealed.
      Parameters:
      set - NavigableSet instance to protect.
      sealedSupplier - Supplier<Boolean> that returns 'true' to indicate sealed, 'false' for mutable.
  • Method Details