- java.lang.Object
-
- de.haumacher.msgbuf.data.AbstractDataObject
-
- de.haumacher.msgbuf.graph.cmd.Command
-
- All Implemented Interfaces:
BinaryDataObject,DataObject
- Direct Known Subclasses:
ListUpdate,SetProperty
public abstract class Command extends AbstractDataObject implements BinaryDataObject
Base class of commands that encode changes to data objects.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCommand.TypeKindType codes for theCommandhierarchy.static interfaceCommand.Visitor<R,A,E extends Throwable>Visitor interface for theCommandhierarchy.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intgetId()The network ID of the changed object.SharedGraphNodegetNode()Cache for the reference to the changed graph node itself.StringgetProperty()The name of the changed property of the object with the givengetId().booleanhasNode()Checks, whethergetNode()has a value.protected voidinternalSetId(int value)Internal setter forgetId()without chain call utility.protected voidinternalSetNode(SharedGraphNode value)Internal setter forgetNode()without chain call utility.protected voidinternalSetProperty(String value)Internal setter forgetProperty()without chain call utility.abstract StringjsonType()The type identifier for this concrete subtype.abstract Command.TypeKindkind()The type code of this instance.static CommandreadCommand(DataReader in)Reads a new instance from the given reader.static CommandreadCommand(JsonReader in)Reads a new instance from the given reader.protected voidreadContent(DataReader in)Helper for reading all fields of this instance.protected voidreadField(DataReader in, int field)Consumes the value for the field with the given ID and assigns its value.protected voidreadField(JsonReader in, String field)Reads the given field from the given input.CommandsetId(int value)CommandsetNode(SharedGraphNode value)CommandsetProperty(String value)abstract <R,A,E extends Throwable>
Rvisit(Command.Visitor<R,A,E> v, A arg)Accepts the given visitor.protected voidwriteFields(DataWriter out)Serializes all fields of this instance to the given binary output.protected voidwriteFields(JsonWriter out)Writes all fields of this instance to the given output.voidwriteTo(DataWriter out)Writes the content of thisDataObjectto the given binary output.voidwriteTo(JsonWriter out)Writes this instance to the given output.-
Methods inherited from class de.haumacher.msgbuf.data.AbstractDataObject
readContent, readFields, toString, writeContent
-
-
-
-
Constructor Detail
-
Command
protected Command()
Creates aCommandinstance.
-
-
Method Detail
-
kind
public abstract Command.TypeKind kind()
The type code of this instance.
-
getId
public final int getId()
The network ID of the changed object.
-
internalSetId
protected final void internalSetId(int value)
Internal setter forgetId()without chain call utility.
-
getProperty
public final String getProperty()
The name of the changed property of the object with the givengetId().
-
setProperty
public Command setProperty(String value)
- See Also:
getProperty()
-
internalSetProperty
protected final void internalSetProperty(String value)
Internal setter forgetProperty()without chain call utility.
-
getNode
public final SharedGraphNode getNode()
Cache for the reference to the changed graph node itself.
-
setNode
public Command setNode(SharedGraphNode value)
- See Also:
getNode()
-
internalSetNode
protected final void internalSetNode(SharedGraphNode value)
Internal setter forgetNode()without chain call utility.
-
hasNode
public final boolean hasNode()
Checks, whethergetNode()has a value.
-
jsonType
public abstract String jsonType()
The type identifier for this concrete subtype.
-
readCommand
public static Command readCommand(JsonReader in) throws IOException
Reads a new instance from the given reader.- Throws:
IOException
-
writeTo
public final void writeTo(JsonWriter out) throws IOException
Description copied from interface:DataObjectWrites this instance to the given output.- Specified by:
writeToin interfaceDataObject- Parameters:
out- TheJsonWriterto write this instance to.- Throws:
IOException- if writing fails.
-
writeFields
protected void writeFields(JsonWriter out) throws IOException
Description copied from class:AbstractDataObjectWrites all fields of this instance to the given output.- Overrides:
writeFieldsin classAbstractDataObject- Parameters:
out- The writer to write to.- Throws:
IOException- If writing fails.
-
readField
protected void readField(JsonReader in, String field) throws IOException
Description copied from class:AbstractDataObjectReads the given field from the given input.- Overrides:
readFieldin classAbstractDataObject- Parameters:
in- The reader to take the value from.field- The name of the field whose value should be read.- Throws:
IOException
-
writeTo
public final void writeTo(DataWriter out) throws IOException
Description copied from interface:BinaryDataObjectWrites the content of thisDataObjectto the given binary output.- Specified by:
writeToin interfaceBinaryDataObject- Parameters:
out- The writer to write this object to.- Throws:
IOException- If writing fails.
-
writeFields
protected void writeFields(DataWriter out) throws IOException
Serializes all fields of this instance to the given binary output.- Parameters:
out- The binary output to write to.- Throws:
IOException- If writing fails.
-
readCommand
public static Command readCommand(DataReader in) throws IOException
Reads a new instance from the given reader.- Throws:
IOException
-
readContent
protected final void readContent(DataReader in) throws IOException
Helper for reading all fields of this instance.- Throws:
IOException
-
readField
protected void readField(DataReader in, int field) throws IOException
Consumes the value for the field with the given ID and assigns its value.- Throws:
IOException
-
visit
public abstract <R,A,E extends Throwable> R visit(Command.Visitor<R,A,E> v, A arg) throws E extends Throwable
Accepts the given visitor.- Throws:
E extends Throwable
-
-