Class 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 class  SimpleCommand.JsonFields
      An enumeration of the known JsonFieldDefinitions 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 Detail

      • of

        public static SimpleCommand of​(String commandName,
                                       String correlationId,
                                       org.eclipse.ditto.json.JsonValue payload)
        Returns a new SimpleCommand instance.
        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 new SimpleCommand from 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 - if jsonString is null.
        IllegalArgumentException - if jsonString is empty.
        org.eclipse.ditto.json.JsonParseException - if the passed in jsonString does not contain a JSON object or if it is not valid JSON.
        org.eclipse.ditto.json.JsonMissingFieldException - if the passed in jsonString was not in the expected 'SimpleCommand' format.
      • fromJson

        public static SimpleCommand fromJson​(org.eclipse.ditto.json.JsonObject jsonObject)
        Creates a new SimpleCommand from 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 - if jsonObject is null.
        IllegalArgumentException - if jsonObject is empty.
        org.eclipse.ditto.json.JsonParseException - if the passed in jsonObject is not valid JSON.
        org.eclipse.ditto.json.JsonMissingFieldException - if the passed in jsonObject was 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:
        toJson in interface org.eclipse.ditto.model.base.json.Jsonifiable<org.eclipse.ditto.json.JsonObject>
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object