- 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 placeidentifies
aUiController
in 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 yourUiController
you need to define anID
. To decouple your navigation from the actualUiController
implementations, it is recommended to define them as constants in a places class per component or module.UiController
s may have mandatory or optionalparameters
. Therefore, it is recommended to createfactory methods
for yourUiPlace
s 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 static
UiPlace
placeAddress(long id) { returnUiPlace
.of(ID_ADDRESS, PARAMETER_ID, id); } public static void navigateAddress(long id) {UiPlace
place = placeAddress(id);UiNavigationManager
.get()
.navigateTo
(place); }- Since:
- 1.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static UiPlace
HOME
The default place to navigate to if the application is started without specifying a customUiPlace
.static UiPlace
NONE
The initial place before the client is initialized by navigating to the first place.static String
PATTERN_KEY
The regex pattern used to assertparameter keys
.static String
PATTERN_VALUE
The regex pattern used to assertparameter values
.static char
SEPARATOR_ANCHOR
The separator for anchor used to prevent thatparameters
are send to the server.static char
SEPARATOR_PARAMETER
The separator used betweenparameters
.static char
SEPARATOR_STATE
The separator fordialog-id
and itsparameters
.static char
SEPARATOR_VALUE
The separator for key and value of aparameter
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
String
get(String key)
This method gets a parameter of thisUiPlace
.String
getId()
Integer
getInt(String key)
This method gets a parameter of thisUiPlace
.int
getInt(String key, int defaultValue)
This method gets a parameter of thisUiPlace
.Map<String,String>
getParameters()
boolean
has(String key)
This method determines if aget(String)
is present (!= null).int
hashCode()
static UiPlace
of(String id)
static UiPlace
of(String id, String key, Object value)
static UiPlace
of(String id, String key1, Object value1, String key2, Object value2)
static UiPlace
of(String id, String key1, Object value1, String key2, Object value2, String key3, Object value3)
static UiPlace
parse(String place)
This is the inverse operation oftoString()
.String
toString()
-
-
-
Field Detail
-
SEPARATOR_STATE
public static final char SEPARATOR_STATE
The separator fordialog-id
and 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 thatparameters
are 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:
getId
in interfaceio.github.mmm.ui.api.attribute.AttributeReadId
- Returns:
- the
ID
of 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:
true
if that parameter is present (NOTnull
),false
otherwise.
-
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
null
if 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
null
if 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 givenkey
is 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
.
-
-