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
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given value to a field with the given name, creating aFields.Field
is none exists for the given name.void
Adds the given value to a field with the given name, creating aFields.Field
is none exists for the given name.void
add
(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.void
void
clear()
Empties thisFields
instance from all fields.static Fields
Combine two Fieldsboolean
getNames()
int
getSize()
Get the number of fields.getValuesOrEmpty
(String name) int
hashCode()
boolean
isEmpty()
iterator()
void
Inserts or replaces the given name/value pair as a single-valuedFields.Field
.void
put
(Fields.Field field) Inserts or replaces the givenFields.Field
, mapped to thefield's name
Removes theFields.Field
with the given name.stream()
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
EMPTY
-
-
Constructor Details
-
Fields
public Fields()Creates an empty, modifiable, case insensitive
Fields
instance. -
Fields
public Fields(boolean caseSensitive) Creates an empty, modifiable, case insensitive
**Fields
instance.- Parameters:
caseSensitive
- whether thisFields
instance must be case sensitive
-
Fields
-
Fields
-
Fields
-
-
Method Details
-
asImmutable
-
equals
-
hashCode
public int hashCode() -
getNames
- Returns:
- a set of field names
-
stream
-
get
- Parameters:
name
- the field name- Returns:
- the
Fields.Field
with the given name, or null if no such field exists
-
getValue
- Parameters:
name
- the field name- Returns:
- the first value of the field with the given name, or null if no such field exists
-
getValues
- Parameters:
name
- the field name- Returns:
- the values of the field with the given name, or null if no such field exists
-
getValuesOrEmpty
- Parameters:
name
- the field name- Returns:
- the values of the field with the given name, or empty list if no such field exists
-
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.Field
is 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.Field
is 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.Field
with 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
Fields
instance from all fields.- See Also:
-
isEmpty
public boolean isEmpty()- Returns:
- whether this
Fields
instance is empty
-
getSize
public int getSize()Get the number of fields.- Returns:
- the number of fields
-
iterator
- Specified by:
iterator
in interfaceIterable<Fields.Field>
- Returns:
- an iterator over the
Fields.Field
s present in this instance
-
toStringArrayMap
- Returns:
- the fields (name and values) of this instance copied into a
Map
-
toMultiMap
- Returns:
- the fields (name and values) of this instance copied into a
MultiMap<String>
-
toString
-
combine
Combine two Fields
- Parameters:
a
- The base Fields or nullb
- The overlay Fields or null- Returns:
- Fields, which may be empty, but never null.
-