- java.lang.Object
-
- io.github.mmm.ui.api.controller.UiPlace
-
- All Implemented Interfaces:
io.github.mmm.ui.api.attribute.AttributeReadId
public final class UiPlace extends Object implements io.github.mmm.ui.api.attribute.AttributeReadId
A placeidentifiesaUiControllerin combination with itsparameters. It allows to represent a specific state of the client that can be bookmarked and reopened at a later point in time.
HINT:
For each of yourUiControlleryou need to define anID. To decouple your navigation from the actualUiControllerimplementations, it is recommended to define them as constants in a places class per component or module.UiControllers may have mandatory or optionalparameters. Therefore, it is recommended to createfactory methodsfor yourUiPlaces in the places class defining the constants that take the parameter values as properly typed arguments. This will make refactoring easier if parameters need to be changed. For generic access to your parameters please also definePARAMETER_*constants in your places class.public final class ExamplePlaces { private ExamplePlaces() {} public static final String ID_ADDRESS = "address"; public static final String PARAMETER_ID = "id"; public staticUiPlaceplaceAddress(long id) { returnUiPlace.of(ID_ADDRESS, PARAMETER_ID, id); } public static void navigateAddress(long id) {UiPlaceplace = placeAddress(id);UiNavigationManager.get().navigateTo(place); }- Since:
- 1.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static UiPlaceHOMEThe default place to navigate to if the application is started without specifying a customUiPlace.static UiPlaceNONEThe initial place before the client is initialized by navigating to the first place.static StringPATTERN_KEYThe regex pattern used to assertparameter keys.static StringPATTERN_VALUEThe regex pattern used to assertparameter values.static charSEPARATOR_ANCHORThe separator for anchor used to prevent thatparametersare send to the server.static charSEPARATOR_PARAMETERThe separator used betweenparameters.static charSEPARATOR_STATEThe separator fordialog-idand itsparameters.static charSEPARATOR_VALUEThe separator for key and value of aparameter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Stringget(String key)This method gets a parameter of thisUiPlace.StringgetId()IntegergetInt(String key)This method gets a parameter of thisUiPlace.intgetInt(String key, int defaultValue)This method gets a parameter of thisUiPlace.Map<String,String>getParameters()booleanhas(String key)This method determines if aget(String)is present (!= null).inthashCode()static UiPlaceof(String id)static UiPlaceof(String id, String key, Object value)static UiPlaceof(String id, String key1, Object value1, String key2, Object value2)static UiPlaceof(String id, String key1, Object value1, String key2, Object value2, String key3, Object value3)static UiPlaceparse(String place)This is the inverse operation oftoString().StringtoString()
-
-
-
Field Detail
-
SEPARATOR_STATE
public static final char SEPARATOR_STATE
The separator fordialog-idand itsparameters.- See Also:
- Constant Field Values
-
SEPARATOR_PARAMETER
public static final char SEPARATOR_PARAMETER
The separator used betweenparameters.- See Also:
- Constant Field Values
-
SEPARATOR_VALUE
public static final char SEPARATOR_VALUE
The separator for key and value of aparameter.- See Also:
- Constant Field Values
-
SEPARATOR_ANCHOR
public static final char SEPARATOR_ANCHOR
The separator for anchor used to prevent thatparametersare send to the server.- See Also:
- Constant Field Values
-
PATTERN_KEY
public static final String PATTERN_KEY
The regex pattern used to assertparameter keys.- See Also:
- Constant Field Values
-
PATTERN_VALUE
public static final String PATTERN_VALUE
The regex pattern used to assertparameter values.- See Also:
- Constant Field Values
-
NONE
public static final UiPlace NONE
The initial place before the client is initialized by navigating to the first place. This is not a valid place to navigate to.
-
-
Constructor Detail
-
UiPlace
public UiPlace(String id)
The constructor.- Parameters:
id- thecontoller ID.
-
UiPlace
public UiPlace(String id, Map<String,String> parameters)
The constructor.- Parameters:
id- thecontoller ID.parameters- theparameters.
-
-
Method Detail
-
getId
public final String getId()
- Specified by:
getIdin interfaceio.github.mmm.ui.api.attribute.AttributeReadId- Returns:
- the
IDof theUiController.
-
has
public boolean has(String key)
This method determines if aget(String)is present (!= null).- Parameters:
key- is the name of the parameter to test.- Returns:
trueif that parameter is present (NOTnull),falseotherwise.
-
get
public String get(String key)
This method gets a parameter of thisUiPlace.- Parameters:
key- is the name of the requested parameter.- Returns:
- the value of the requested parameter. Will be
nullif not set.
-
getInt
public Integer getInt(String key)
This method gets a parameter of thisUiPlace.- Parameters:
key- is the name of the requested parameter.- Returns:
- the value of the requested parameter. Will be
nullif not set.
-
getInt
public int getInt(String key, int defaultValue)
This method gets a parameter of thisUiPlace.- Parameters:
key- is the name of the requested parameter.defaultValue- the default value to return if the parameter with the givenkeyis notdefined.- Returns:
- the value of the requested parameter.
-
parse
public static UiPlace parse(String place)
This is the inverse operation oftoString().
-
of
public static UiPlace of(String id)
- Parameters:
id- is thecontroller ID.- Returns:
- the new
UiPlace.
-
of
public static UiPlace of(String id, String key, Object value)
- Parameters:
id- is thecontroller ID.key- theparameter key.value- theparameter value.- Returns:
- the new
UiPlace.
-
of
public static UiPlace of(String id, String key1, Object value1, String key2, Object value2)
- Parameters:
id- is thecontroller ID.key1- the firstparameter key.value1- the fistparameter value.key2- the secondparameter key.value2- the secondparameter value.- Returns:
- the new
UiPlace.
-
of
public static UiPlace of(String id, String key1, Object value1, String key2, Object value2, String key3, Object value3)
- Parameters:
id- is thecontroller ID.key1- the firstparameter key.value1- the fistparameter value.key2- the secondparameter key.value2- the secondparameter value.key3- the thirdparameter key.value3- the thirdparameter value.- Returns:
- the new
UiPlace.
-
-