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
ModifierConstructorDescriptionBasicNamedAttribute
(String name, Object value) Constructor.protected
Copy 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.boolean
Returnstrue if the value exists.static BasicNamedAttribute
Static creator.static BasicNamedAttribute
Static creator with delayed value.static BasicNamedAttribute
Creates aBasicNamedAttribute
from 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
BasicPart
object.
-
ofPair
Creates aBasicNamedAttribute
from a name/value pair string (e.g."Foo: bar" )- Parameters:
pair
- The pair string.- Returns:
- A new
NameValuePair
object.
-
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
BasicPart
object.
-
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.
-
getName
Description copied from interface:NamedAttribute
Returns the attribute name.- Specified by:
getName
in interfaceNamedAttribute
- Returns:
- The attribute name.
-
getValue
Description copied from interface:NamedAttribute
Returns the attribute value.- Specified by:
getValue
in 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.
-
get
If a value is present, returns the value, otherwise throwsNoSuchElementException
.This is a shortcut for calling
asString().get() .- Returns:
- The value if present.
-
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
-