Package de.xima.fc.gui.common.utils
Class RemoteCommandUtils
- java.lang.Object
- 
- de.xima.fc.gui.common.utils.RemoteCommandUtils
 
- 
 public final class RemoteCommandUtils extends Object Helper methods for<p:remoteCommand>, such as reading parameters and returning a value.- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
 
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddError(Throwable e)Sets the success return value tofalseand also add the error message as a return parameter.static voidaddReturnValue(String paramName, boolean value)Adds a return value for the remote command with the given parameter name.static voidaddReturnValue(String paramName, int value)Adds a return value for the remote command with the given parameter name.static voidaddReturnValue(String paramName, long value)Adds a return value for the remote command with the given parameter name.static voidaddReturnValue(String paramName, Object value)Adds a return value for the remote command with the given parameter name.static voidaddSuccess()Sets the success return parameter totrue.static StringdelayResponse()Can be used when the response to a remote command cannot be computed synchronously.static booleangetBoolean(String paramName)static Optional<Boolean>getBooleanOptional(String paramName)static <T extends Enum<T>>
 TgetEnum(String paramName, Class<T> enumType)static <T> List<T>getJsonArray(String paramName, Class<T> clazz)static com.alibaba.fastjson.JSONObjectgetJsonObject(String paramName)static com.alibaba.fastjson.JSONObjectgetJsonObject(String paramName, com.alibaba.fastjson.JSONObject defaultValue)static <T> TgetJsonObject(String paramName, Class<T> clazz)static <T> TgetJsonObject(String paramName, Class<T> clazz, T defaultValue)static Optional<List<Long>>getListOfLongs(String paramName)static List<String>getListOfStrings(String paramName)static LocalegetLocale(String paramName)static LocalegetLocale(String paramName, Locale defaultValue)static OptionalLonggetLong(String paramName)static longgetLong(String paramName, long defaultValue)static Optional<com.vdurmont.semver4j.Semver>getSemver(String paramName, com.vdurmont.semver4j.Semver.SemverType type)static com.vdurmont.semver4j.SemvergetSemver(String paramName, com.vdurmont.semver4j.Semver.SemverType type, com.vdurmont.semver4j.Semver defaultValue)static Set<String>getSetOfStrings(String paramName)static StringgetString(String paramName)static StringgetString(String paramName, String defaultValue)static Optional<String>getStringOptional(String paramName)static voidresolveDelayed(String delayId)Marks the response as the result for the given delay ID.
 
- 
- 
- 
Method Detail- 
addErrorpublic static void addError(Throwable e) Sets the success return value tofalseand also add the error message as a return parameter.- Parameters:
- e- Exception that occurred.
 
 - 
addReturnValuepublic static void addReturnValue(String paramName, boolean value) Adds a return value for the remote command with the given parameter name. Also sets the success return parameter totrue.- Parameters:
- paramName- Name of the parameter, can be used on the client to access the parameter.
- value- Boolean value to be returned.
 
 - 
addReturnValuepublic static void addReturnValue(String paramName, int value) Adds a return value for the remote command with the given parameter name. Also sets the success return parameter totrue.- Parameters:
- paramName- Name of the parameter, can be used on the client to access the parameter.
- value- Integer value to be returned.
 
 - 
addReturnValuepublic static void addReturnValue(String paramName, long value) Adds a return value for the remote command with the given parameter name. Also sets the success return parameter totrue.- Parameters:
- paramName- Name of the parameter, can be used on the client to access the parameter.
- value- Long value to be returned.
 
 - 
addReturnValuepublic static void addReturnValue(String paramName, Object value) Adds a return value for the remote command with the given parameter name. Also sets the success return parameter totrue.- Parameters:
- paramName- Name of the parameter, can be used on the client to access the parameter.
- value- Value to be returned. This value is stringified.
 
 - 
addSuccesspublic static void addSuccess() Sets the success return parameter totrue.
 - 
delayResponsepublic static String delayResponse() Can be used when the response to a remote command cannot be computed synchronously. Returns a delay ID that should be passed toresolveDelayed(String).- Returns:
- The delay ID that must be used to resolve the delayed remote command. Must be passed to
 resolveDelayed(String)or the client-side promise will never resolve
 
 - 
getBooleanpublic static boolean getBoolean(String paramName) - Parameters:
- paramName- Name of the parameter to read.
- Returns:
- The boolean value of the parameter, falsewhen the parameter is not present.
 
 - 
getBooleanOptionalpublic static Optional<Boolean> getBooleanOptional(String paramName) - Parameters:
- paramName- Name of the parameter to read.
- Returns:
- The boolean value of the parameter, empty optional when the parameter is not present.
 
 - 
getEnumpublic static <T extends Enum<T>> T getEnum(String paramName, Class<T> enumType) - Type Parameters:
- T- Type of the enum.
- Parameters:
- paramName- Name of the parameter to read.
- enumType- Type of the enum.
- Returns:
- The enum value of the parameter, or nullwhen the parameter is not present or no such enum constant exists.
 
 - 
getJsonArraypublic static <T> List<T> getJsonArray(String paramName, Class<T> clazz) - Type Parameters:
- T- Type to create from the JSON.
- Parameters:
- paramName- Name of the parameter to read.
- clazz- Type to create from the JSON.
- Returns:
- The value of the parameter parsed as a deserialized list, empty list if no such parameter exists or it is invalid.
 
 - 
getJsonObjectpublic static com.alibaba.fastjson.JSONObject getJsonObject(String paramName) - Parameters:
- paramName- Name of the parameter to read.
- Returns:
- The value of the parameter parsed as a JSON object, empty object if no such parameter exists or it is invalid.
 
 - 
getJsonObjectpublic static <T> T getJsonObject(String paramName, Class<T> clazz) - Type Parameters:
- T- Type to create from the JSON.
- Parameters:
- paramName- Name of the parameter to read.
- clazz- Type to create from the JSON.
- Returns:
- The value of the parameter parsed as a deserialized object, null if no such parameter exists or it is invalid.
 
 - 
getJsonObjectpublic static <T> T getJsonObject(String paramName, Class<T> clazz, T defaultValue) - Type Parameters:
- T- Type to create from the JSON.
- Parameters:
- paramName- Name of the parameter to read.
- clazz- Type to create from the JSON.
- defaultValue- Default value to return when the parameter could not be read.
- Returns:
- The value of the parameter parsed as a deserialized object, default value if no such parameter exists or it is invalid.
 
 - 
getJsonObjectpublic static com.alibaba.fastjson.JSONObject getJsonObject(String paramName, com.alibaba.fastjson.JSONObject defaultValue) - Parameters:
- paramName- Name of the parameter to read.
- defaultValue- Default value used when parameter does not exist or is invalid.
- Returns:
- The value of the parameter parsed as a JSON object, default value if no such parameter exists or it is invalid.
 
 - 
getListOfLongspublic static Optional<List<Long>> getListOfLongs(String paramName) - Parameters:
- paramName- Name of the parameter to read. Never- null, only empty.
- Returns:
- A list of all values for the given parameter.
 
 - 
getListOfStringspublic static List<String> getListOfStrings(String paramName) - Parameters:
- paramName- Name of the parameter to read. Never- null, only empty.
- Returns:
- A list of all values for the given parameter.
 
 - 
getLocalepublic static Locale getLocale(String paramName) - Parameters:
- paramName- Name of the parameter to read.
- Returns:
- The locale indicated by the parameter, or nullif no such parameter exists.
 
 - 
getLocalepublic static Locale getLocale(String paramName, Locale defaultValue) - Parameters:
- paramName- Name of the parameter to read.
- defaultValue- Default value used when parameter does not exist.
- Returns:
- The locale indicated by the parameter, or the default value if no such parameter exists.
 
 - 
getLongpublic static OptionalLong getLong(String paramName) - Parameters:
- paramName- Name of the parameter to read.
- Returns:
- The long value of the parameter, empty if no such parameter exists or it its not a valid long.
 
 - 
getLongpublic static long getLong(String paramName, long defaultValue) - Parameters:
- paramName- Name of the parameter to read.
- defaultValue- Default value used when parameter does not exist or is not a valid long.
- Returns:
- The long value of the parameter, default value if no such parameter exists or it its not a valid long.
 
 - 
getSemverpublic static Optional<com.vdurmont.semver4j.Semver> getSemver(String paramName, com.vdurmont.semver4j.Semver.SemverType type) - Parameters:
- paramName- Name of the parameter to read.
- type- Semver type to use for parsing.
- Returns:
- The boolean value of the parameter, falsewhen the parameter is not present.
 
 - 
getSemverpublic static com.vdurmont.semver4j.Semver getSemver(String paramName, com.vdurmont.semver4j.Semver.SemverType type, com.vdurmont.semver4j.Semver defaultValue) - Parameters:
- paramName- Name of the parameter to read.
- type- Semver type to use for parsing.
- defaultValue- Default used when the value cannot be parsed as a semver.
- Returns:
- The boolean value of the parameter, falsewhen the parameter is not present.
 
 - 
getSetOfStringspublic static Set<String> getSetOfStrings(String paramName) - Parameters:
- paramName- Name of the parameter to read. Never- null, only empty.
- Returns:
- A set of all values for the given parameter.
 
 - 
getStringpublic static String getString(String paramName) - Parameters:
- paramName- Name of the parameter to read.
- Returns:
- The string value of the parameter, empty string if no such parameter exists.
 
 - 
getStringpublic static String getString(String paramName, String defaultValue) - Parameters:
- paramName- Name of the parameter to read.
- defaultValue- Default value used when parameter does not exist.
- Returns:
- The string value of the parameter, or the default value if no such parameter exists.
 
 - 
getStringOptionalpublic static Optional<String> getStringOptional(String paramName) - Parameters:
- paramName- Name of the parameter to read.
- Returns:
- The string value of the parameter, empty optional if no such parameter exists.
 
 - 
resolveDelayedpublic static void resolveDelayed(String delayId) Marks the response as the result for the given delay ID. Must be called after all other calls that add values, such asaddSuccess(),addError(Throwable),addReturnValue(String, boolean)etc.- Parameters:
- delayId- The delay ID that was returned form- delayResponse().
 
 
- 
 
-