Class Fields
- All Implemented Interfaces:
Iterable<Fields.Field>
A container for name/value pairs, known as fields.
A Fields.Field is immutable and is composed of a name string that can be case-sensitive
or case-insensitive (by specifying the option at the constructor) and
of a case-sensitive set of value strings.
The implementation of this class is not thread safe.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFields()Creates an empty, modifiable, case insensitiveFieldsinstance.Fields(boolean caseSensitive) Creates an empty, modifiableFieldsinstance.Fields(Map<String, Fields.Field> fields) Creates aFieldsinstance from a map of fields.Creates a copy of the givenFieldsinstance.Creates aFieldsinstance from a MultiMap. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given value to a field with the given name, creating aFields.Fieldis none exists for the given name.voidAdds the given value to a field with the given name, creating aFields.Fieldis none exists for the given name.voidadd(Fields.Field field) Adds the given field, storing it if none exists for the given name, or adding all the values to the existing field with the given name.voidvoidclear()Empties thisFieldsinstance from all fields.static FieldsCombine two FieldsbooleangetNames()intgetSize()Get the number of fields.getValuesOrEmpty(String name) inthashCode()booleanisEmpty()iterator()voidInserts or replaces the given name/value pair as a single-valuedFields.Field.voidput(Fields.Field field) Inserts or replaces the givenFields.Field, mapped to thefield's nameRemoves theFields.Fieldwith the given name.stream()toString()Methods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
EMPTY
-
-
Constructor Details
-
Fields
public Fields()Creates an empty, modifiable, case insensitive
Fieldsinstance. -
Fields
public Fields(boolean caseSensitive) Creates an empty, modifiable
Fieldsinstance.- Parameters:
caseSensitive- whether thisFieldsinstance must be case sensitive
-
Fields
-
Fields
Creates aFieldsinstance from a map of fields.- Parameters:
fields- the map of fields to use
-
Fields
Creates a copy of the givenFieldsinstance.- Parameters:
fields- the fields to copy
-
-
Method Details
-
asImmutable
- Returns:
- an immutable view of this fields instance
-
equals
-
hashCode
-
getNames
-
stream
-
get
- Parameters:
name- the field name- Returns:
- the
Fields.Fieldwith the given name, or null if no such field exists
-
getValue
-
getValues
-
getValuesOrEmpty
-
put
Inserts or replaces the given name/value pair as a single-valued
Fields.Field.- Parameters:
name- the field namevalue- the field value
-
put
Inserts or replaces the given
Fields.Field, mapped to thefield's name- Parameters:
field- the field to put
-
add
Adds the given value to a field with the given name, creating a
Fields.Fieldis none exists for the given name.- Parameters:
name- the field namevalue- the field value to add
-
add
Adds the given value to a field with the given name, creating a
Fields.Fieldis none exists for the given name.- Parameters:
name- the field namevalues- the field values to add
-
add
Adds the given field, storing it if none exists for the given name, or adding all the values to the existing field with the given name.
- Parameters:
field- the field to add
-
addAll
-
remove
Removes the
Fields.Fieldwith the given name.- Parameters:
name- the name of the field to remove- Returns:
- the removed field, or null if no such field existed
-
clear
public void clear()Empties this
Fieldsinstance from all fields.- See Also:
-
isEmpty
public boolean isEmpty()- Returns:
- whether this
Fieldsinstance is empty
-
getSize
public int getSize()Get the number of fields.- Returns:
- the number of fields
-
iterator
- Specified by:
iteratorin interfaceIterable<Fields.Field>- Returns:
- an iterator over the
Fields.Fields present in this instance
-
toStringArrayMap
-
toMultiMap
-
toString
-
combine
-