Package org.apache.juneau.rest.httppart
Class BasicNamedAttribute
java.lang.Object
org.apache.juneau.rest.httppart.BasicNamedAttribute
- All Implemented Interfaces:
NamedAttribute
- Direct Known Subclasses:
RequestAttribute
Implementation of a named object.
See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionBasicNamedAttribute(String name, Object value) Constructor.protectedCopy constructor. -
Method Summary
Modifier and TypeMethodDescriptionProvides an object for performing assertions against the name of this pair.Provides an object for performing assertions against the value of this pair.get()If a value is present, returns the value, otherwise throwsNoSuchElementException.getName()Returns the attribute name.getValue()Returns the attribute value.booleanReturnstrue if the value exists.static BasicNamedAttributeStatic creator.static BasicNamedAttributeStatic creator with delayed value.static BasicNamedAttributeCreates aBasicNamedAttributefrom a name/value pair string (e.g.If a value is present, returns the value, otherwise returns other.toString()
-
Constructor Details
-
BasicNamedAttribute
Constructor.- Parameters:
name- The parameter name.value- The POJO to serialize to the parameter value.
-
BasicNamedAttribute
Copy constructor.- Parameters:
copyOf- The object to copy.
-
-
Method Details
-
of
Static creator.- Parameters:
name- The parameter name.value- The parameter value.- Returns:
- A new
BasicPartobject.
-
of
Static creator with delayed value.Value is re-evaluated on each call to
getValue().- Parameters:
name- The parameter name.value- The parameter value supplier.- Returns:
- A new
BasicPartobject.
-
ofPair
Creates aBasicNamedAttributefrom a name/value pair string (e.g."Foo: bar" )- Parameters:
pair- The pair string.- Returns:
- A new
NameValuePairobject.
-
assertName
Provides an object for performing assertions against the name of this pair.- Returns:
- An object for performing assertions against the name of this pair.
-
assertValue
Provides an object for performing assertions against the value of this pair.- Returns:
- An object for performing assertions against the value of this pair.
-
get
If a value is present, returns the value, otherwise throwsNoSuchElementException.This is a shortcut for calling
asString().get() .- Returns:
- The value if present.
-
getName
Description copied from interface:NamedAttributeReturns the attribute name.- Specified by:
getNamein interfaceNamedAttribute- Returns:
- The attribute name.
-
getValue
Description copied from interface:NamedAttributeReturns the attribute value.- Specified by:
getValuein interfaceNamedAttribute- Returns:
- The attribute value.
-
isPresent
Returnstrue if the value exists.This is a shortcut for calling
asString().isPresent() .- Returns:
true if the value exists.
-
orElse
If a value is present, returns the value, otherwise returns other.This is a shortcut for calling
asString().orElse( .other )- Parameters:
other- The other value.- Returns:
- The value if present or the other value if not.
-
toString
-