Interface RepresentationModel
- All Known Subinterfaces:
ErrorRepresentationModel
public interface RepresentationModel
This class provides a view of the response model information present in a
Response,
to be used by RepresentationFunction.- Since:
- 5.4.0
-
Method Summary
Modifier and TypeMethodDescription<T> TReturn theRepresentationModelassociated tokey.booleangetBoolean(String key) Return thebooleanassociated tokey.booleangetBoolean(String key, boolean defaultValue) Return thebooleanassociated tokey.intReturn theintassociated tokey.longReturn thelongassociated tokey.<T> Optional<T>getOptionalAs(String key, Class<T> type) Return anOptionalwith theRepresentationModelassociated tokey, or an emptyOptionalis such key doesn't exist.getOptionalBoolean(String key) getOptionalInt(String key) Return anOptionalIntwith theintassociated tokey, or an emptyOptionalIntis such key doesn't exist.getOptionalLong(String key) Return anOptionalIntwith thelongassociated tokey, or an emptyOptionalIntis such key doesn't exist.getOptionalString(String key) Return theStringassociated tokey.Returns aMapwith the model's view data.
-
Method Details
-
getString
Return theStringassociated tokey.- Parameters:
key- the key to lookup- Returns:
- the
Stringassociated tokey - Throws:
NoSuchElementException- the model does not contain any entry forkeyClassCastException- the value associated tokeyis not convertible to aString
-
getInt
Return theintassociated tokey.- Parameters:
key- the key to lookup- Returns:
- the
intassociated tokey - Throws:
NoSuchElementException- the model does not contain any entry forkeyClassCastException- the value associated tokeyis not convertible to aint
-
getLong
Return thelongassociated tokey.- Parameters:
key- the key to lookup- Returns:
- the
longassociated tokey - Throws:
NoSuchElementException- the model does not contain any entry forkeyClassCastException- the value associated tokeyis not convertible to along
-
getBoolean
Return thebooleanassociated tokey.- Parameters:
key- the key to lookup- Returns:
- the
booleanassociated tokey - Throws:
NoSuchElementException- the model does not contain any entry forkeyClassCastException- the value associated tokeyis not convertible to aboolean
-
getBoolean
Return thebooleanassociated tokey.- Parameters:
key- the key to lookupdefaultValue- the default value to use if the model doesn't contain any entry forkey- Returns:
- the
booleanassociated tokeyor the default value. - Throws:
ClassCastException- the value associated tokeyis not convertible to aboolean
-
getAs
Return theRepresentationModelassociated tokey.- Type Parameters:
T- the type of the value being retrived from the model- Parameters:
key- the key to lookup- Returns:
- the
RepresentationModelassociated tokey - Throws:
NoSuchElementException- the model does not contain any entry forkeyClassCastException- the value associated tokeyis not convertible to aRepresentationModel
-
getOptionalString
Return anOptionalwith theStringassociated tokey, or an emptyOptionalis such key doesn't exist.- Parameters:
key- the key to lookup- Returns:
- the
Optionalwith the optional value associated tokey - Throws:
ClassCastException- the value associated tokeyis not convertible to aString
-
getOptionalInt
Return anOptionalIntwith theintassociated tokey, or an emptyOptionalIntis such key doesn't exist.- Parameters:
key- the key to lookup- Returns:
- the
OptionalIntwith the optional value associated tokey - Throws:
ClassCastException- the value associated tokeyis not convertible to aint
-
getOptionalLong
Return anOptionalIntwith thelongassociated tokey, or an emptyOptionalIntis such key doesn't exist.- Parameters:
key- the key to lookup- Returns:
- the
OptionalIntwith the optional value associated tokey - Throws:
ClassCastException- the value associated tokeyis not convertible to along
-
getOptionalBoolean
Return anOptionalwith thebooleanassociated tokey, or an emptyOptionalis such key doesn't exist.- Parameters:
key- the key to lookup- Returns:
- the
Optionalwith the optional value associated tokey - Throws:
ClassCastException- the value associated tokeyis not convertible to aboolean
-
getOptionalAs
Return anOptionalwith theRepresentationModelassociated tokey, or an emptyOptionalis such key doesn't exist.- Parameters:
key- the key to lookup- Returns:
- the
Optionalwith the optional value associated tokey - Throws:
ClassCastException- the value associated tokeyis not convertible to aRepresentationModel
-
getViewData
Returns aMapwith the model's view data. The use of typed accessors, such asgetString(String)andgetOptionalAs(String, Class), should be preferred.- Returns:
- the view data associated with the model.
-