Class FieldSet<T>

java.lang.Object
com.univocity.parsers.common.fields.FieldSet<T>
Type Parameters:
T - the type of the reference information used to uniquely identify a field (e.g. references to field indexes would use Integer, while references to field names would use String).
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
ExcludeFieldEnumSelector, ExcludeFieldIndexSelector, ExcludeFieldNameSelector, FieldEnumSelector, FieldIndexSelector, FieldNameSelector

public class FieldSet<T> extends Object implements Cloneable
A set of selected fields.

Used by CommonSettings to select fields for reading/writing

Also used by com.univocity.parsers.common.processor.ConversionProcessor to select fields that have to be converted.

See Also:
  • Field Details

    • fields

      private List<T> fields
    • wrappedFieldSets

      private List<FieldSet<T>> wrappedFieldSets
  • Constructor Details

    • FieldSet

      public FieldSet()
      Creates am empty field set. For internal use only.
    • FieldSet

      public FieldSet(List<FieldSet<T>> wrappedFieldSets)
      Creates a field set that wraps a collection of other field sets. For internal use only.
      Parameters:
      wrappedFieldSets - the field sets to be wrapped.
  • Method Details

    • get

      public List<T> get()
      Returns a copy of the fields in this set
      Returns:
      a copy of the fields in this set
    • set

      public FieldSet<T> set(T... fields)
      Validates and sets multiple field references. Any existing reference will be discarded.
      Parameters:
      fields - information that uniquely identifies each field
      Returns:
      the set of currently selected fields
    • add

      public FieldSet<T> add(T... fields)
      Validates and adds multiple field references
      Parameters:
      fields - information that uniquely identifies each field
      Returns:
      the set of currently selected fields
    • addElement

      private void addElement(T field)
      Validates and adds a reference to a field.
      Parameters:
      field - information that uniquely identifies a field
    • set

      public FieldSet<T> set(Collection<T> fields)
      Validates and sets multiple field references. Any existing reference will be discarded.
      Parameters:
      fields - information that uniquely identifies each field
      Returns:
      the set of currently selected fields
    • add

      public FieldSet<T> add(Collection<T> fields)
      Validates and adds multiple field references
      Parameters:
      fields - information that uniquely identifies each field
      Returns:
      the set of currently selected fields
    • remove

      public FieldSet<T> remove(T... fields)
      Removes multiple field references in the selection
      Parameters:
      fields - information that uniquely identifies each field
      Returns:
      the set of currently selected fields
    • remove

      public FieldSet<T> remove(Collection<T> fields)
      Removes multiple field references in the selection
      Parameters:
      fields - information that uniquely identifies each field
      Returns:
      the set of currently selected fields
    • describe

      public String describe()
      Returns a string that represents the current field selection
      Returns:
      a string that represents the current field selection
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • clone

      public FieldSet<T> clone()
      Overrides:
      clone in class Object