Class CompactCIHashSet<E>

java.lang.Object
com.cedarsoftware.util.CompactSet<E>
com.cedarsoftware.util.CompactCIHashSet<E>
Type Parameters:
E - the type of elements maintained by this set
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>

public class CompactCIHashSet<E> extends CompactSet<E>
A case-insensitive Set implementation that uses a compact internal representation for small sets. This Set exists to simplify JSON serialization. No custom reader nor writer is needed to serialize this set. It is a drop-in replacement for HashSet if you want case-insensitive behavior for Strings and compactness.
Author:
John DeRegnaucourt ([email protected])
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

    • CompactCIHashSet

      public CompactCIHashSet()
      Constructs an empty CompactCIHashSet with case-insensitive configuration.

      Specifically, it sets the set to be case-insensitive.

      Throws:
      IllegalArgumentException - if CompactSet.compactSize() returns a value less than 2
    • CompactCIHashSet

      public CompactCIHashSet(Collection<E> other)
      Constructs a CompactCIHashSet containing the elements of the specified collection.

      The set will be case-insensitive.

      Parameters:
      other - the collection whose elements are to be placed into this set
      Throws:
      NullPointerException - if the specified collection is null
      IllegalArgumentException - if CompactSet.compactSize() returns a value less than 2
  • Method Details

    • isCaseInsensitive

      protected boolean isCaseInsensitive()
      Indicates that this set is case-insensitive.
      Overrides:
      isCaseInsensitive in class CompactSet<E>
      Returns:
      true to denote case-insensitive behavior
    • getNewSet

      protected Set<E> getNewSet()
      Description copied from class: CompactSet
      Allow concrete subclasses to specify the internal set to use when larger than compactSize. Concrete subclasses are useful to simplify serialization.
      Overrides:
      getNewSet in class CompactSet<E>