Class SimpleCommand
- java.lang.Object
-
- org.eclipse.ditto.services.utils.akka.SimpleCommand
-
- All Implemented Interfaces:
org.eclipse.ditto.model.base.json.Jsonifiable<org.eclipse.ditto.json.JsonObject>
@Immutable public final class SimpleCommand extends Object implements org.eclipse.ditto.model.base.json.Jsonifiable<org.eclipse.ditto.json.JsonObject>
Internal simple command which is Jsonifiable, has a command name, an optional correlationId and optionally payload.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSimpleCommand.JsonFieldsAn enumeration of the knownJsonFieldDefinitions of a SimpleCommand.-
Nested classes/interfaces inherited from interface org.eclipse.ditto.model.base.json.Jsonifiable
org.eclipse.ditto.model.base.json.Jsonifiable.WithFieldSelector, org.eclipse.ditto.model.base.json.Jsonifiable.WithFieldSelectorAndPredicate<T extends Object>, org.eclipse.ditto.model.base.json.Jsonifiable.WithPointer<J extends org.eclipse.ditto.json.JsonValue>, org.eclipse.ditto.model.base.json.Jsonifiable.WithPredicate<J extends org.eclipse.ditto.json.JsonValue,T extends Object>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)static SimpleCommandfromJson(String jsonString)Creates a newSimpleCommandfrom a JSON string.static SimpleCommandfromJson(org.eclipse.ditto.json.JsonObject jsonObject)Creates a newSimpleCommandfrom a JSON object.StringgetCommandName()Returns the name of the SimpleCommand.Optional<String>getCorrelationId()Returns the optional correlationId of the SimpleCommand.Optional<org.eclipse.ditto.json.JsonValue>getPayload()Returns the optional JSON payload of the SimpleCommand.inthashCode()static SimpleCommandof(String commandName, String correlationId, org.eclipse.ditto.json.JsonValue payload)Returns a newSimpleCommandinstance.org.eclipse.ditto.json.JsonObjecttoJson()StringtoString()
-
-
-
Method Detail
-
of
public static SimpleCommand of(String commandName, String correlationId, org.eclipse.ditto.json.JsonValue payload)
Returns a newSimpleCommandinstance.- Parameters:
commandName- the name of the command.correlationId- an optional identifier correlating a SimpleCommand to a SimpleCommandResponse.payload- optional payload to transmit with the SimpleCommand.- Returns:
- the new SimpleCommand instance.
-
fromJson
public static SimpleCommand fromJson(String jsonString)
Creates a newSimpleCommandfrom a JSON string.- Parameters:
jsonString- the JSON string of which a new SimpleCommand is to be created.- Returns:
- the SimpleCommand which was created from the given JSON string.
- Throws:
NullPointerException- ifjsonStringisnull.IllegalArgumentException- ifjsonStringis empty.org.eclipse.ditto.json.JsonParseException- if the passed injsonStringdoes not contain a JSON object or if it is not valid JSON.org.eclipse.ditto.json.JsonMissingFieldException- if the passed injsonStringwas not in the expected 'SimpleCommand' format.
-
fromJson
public static SimpleCommand fromJson(org.eclipse.ditto.json.JsonObject jsonObject)
Creates a newSimpleCommandfrom a JSON object.- Parameters:
jsonObject- the JSON object of which a new SimpleCommand is to be created.- Returns:
- the SimpleCommand which was created from the given JSON object.
- Throws:
NullPointerException- ifjsonObjectisnull.IllegalArgumentException- ifjsonObjectis empty.org.eclipse.ditto.json.JsonParseException- if the passed injsonObjectis not valid JSON.org.eclipse.ditto.json.JsonMissingFieldException- if the passed injsonObjectwas not in the expected 'SimpleCommand' format.
-
getCommandName
public String getCommandName()
Returns the name of the SimpleCommand.- Returns:
- the name of the SimpleCommand.
-
getCorrelationId
public Optional<String> getCorrelationId()
Returns the optional correlationId of the SimpleCommand.- Returns:
- the optional correlationId of the SimpleCommand.
-
getPayload
public Optional<org.eclipse.ditto.json.JsonValue> getPayload()
Returns the optional JSON payload of the SimpleCommand.- Returns:
- the optional JSON payload of the SimpleCommand.
-
toJson
public org.eclipse.ditto.json.JsonObject toJson()
- Specified by:
toJsonin interfaceorg.eclipse.ditto.model.base.json.Jsonifiable<org.eclipse.ditto.json.JsonObject>
-
-