Class TypeParser
- Author:
- Kai Kreuzer - Initial contribution
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable Command
parseCommand
(List<Class<? extends Command>> types, String s) Determines a command from a string.static @Nullable State
parseState
(List<Class<? extends State>> types, String s) Determines a state from a string.static @Nullable Type
Parses a string into a type.
-
Method Details
-
parseType
Parses a string into a type.- Parameters:
typeName
- name of the type, for example StringType.input
- input string to parse.- Returns:
- Parsed type or null, if the type couldn't be parsed.
-
parseState
Determines a state from a string. Possible state types are passed as a parameter. Note that the order matters here; the first type that accepts the string as a valid value, will be used for the state.
Example: The type list is OnOffType.class,StringType.class. The string "ON" is now accepted by the OnOffType and thus OnOffType.ON will be returned (and not a StringType with value "ON").
- Parameters:
types
- possible types of the state to considers
- the string to parse- Returns:
- the corresponding State instance or
null
-
parseCommand
Determines a command from a string. Possible command types are passed as a parameter. Note that the order matters here; the first type that accepts the string as a valid value, will be used for the command.
Example: The type list is OnOffType.class,StringType.class. The string "ON" is now accepted by the OnOffType and thus OnOffType.ON will be returned (and not a StringType with value "ON").
- Parameters:
types
- possible types of the command to considers
- the string to parse- Returns:
- the corresponding Command instance or
null
-