java.lang.Object
de.haumacher.msgbuf.data.AbstractDataObject
de.haumacher.msgbuf.graph.cmd.Command
- All Implemented Interfaces:
BinaryDataObject,DataObject,ReflectiveDataObject,Observable
- Direct Known Subclasses:
ListUpdate,SetProperty
Base class of commands that encode changes to data objects.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves value of the field with the given name.final intgetId()The network ID of the changed object.final SharedGraphNodegetNode()Cache for the reference to the changed graph node itself.final StringThe name of the changed property of the object with the givengetId().final booleanhasNode()Checks, whethergetNode()has a value.abstract Command.TypeKindkind()The type code of this instance.All properties that are supported by this object.static CommandReads a new instance from the given reader.static CommandReads a new instance from the given reader.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.Attaches the givenListenerto this object.voidSets the value of the property with the given name.final CommandsetId(int value) final CommandsetNode(SharedGraphNode value) final CommandsetProperty(String value) abstract inttypeId()The binary identifier for this concrete type in the polymorphicCommandhierarchy.Removes the givenListenerfrom this object.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.final voidwriteTo(DataWriter out) Writes the content of thisDataObjectto the given binary output.final voidwriteTo(JsonWriter out) Writes this instance to the given output.Methods inherited from class de.haumacher.msgbuf.data.AbstractDataObject
readContent, readFields, toString, writeContentMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface de.haumacher.msgbuf.data.ReflectiveDataObject
jsonType
-
Field Details
-
ID
- See Also:
-
PROPERTY
- See Also:
-
NODE
- See Also:
-
ID__ID
public static final int ID__IDIdentifier for the propertygetId()in binary format.- See Also:
-
PROPERTY__ID
public static final int PROPERTY__IDIdentifier for the propertygetProperty()in binary format.- See Also:
-
_listener
-
-
Constructor Details
-
Command
protected Command()Creates aCommandinstance.
-
-
Method Details
-
kind
The type code of this instance. -
getId
public final int getId()The network ID of the changed object. -
setId
- See Also:
-
getProperty
The name of the changed property of the object with the givengetId(). -
setProperty
- See Also:
-
getNode
Cache for the reference to the changed graph node itself. -
hasNode
public final boolean hasNode()Checks, whethergetNode()has a value. -
registerListener
Description copied from interface:ObservableAttaches the givenListenerto this object.If the given
Listeneris already attached, it is not attached again.- Specified by:
registerListenerin interfaceObservable- Parameters:
l- TheListenerto attach.- Returns:
- This object for call chaining.
-
unregisterListener
Description copied from interface:ObservableRemoves the givenListenerfrom this object.- Specified by:
unregisterListenerin interfaceObservable- Parameters:
l- TheListenerto remove.- Returns:
- This object for call chaining.
-
properties
Description copied from interface:ReflectiveDataObjectAll properties that are supported by this object.- Specified by:
propertiesin interfaceReflectiveDataObject- See Also:
-
get
Description copied from interface:ReflectiveDataObjectRetrieves value of the field with the given name.- Specified by:
getin interfaceReflectiveDataObject- Parameters:
field- The name of the property.- Returns:
- The value of the property with the given name.
- See Also:
-
set
Description copied from interface:ReflectiveDataObjectSets the value of the property with the given name.- Specified by:
setin interfaceReflectiveDataObject- Parameters:
field- The name of the property to update.value- The new value of the property.- See Also:
-
readCommand
Reads a new instance from the given reader.- Throws:
IOException
-
writeTo
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
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
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
-
typeId
public abstract int typeId()The binary identifier for this concrete type in the polymorphicCommandhierarchy. -
writeTo
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
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
Reads a new instance from the given reader.- Throws:
IOException
-
readField
Consumes the value for the field with the given ID and assigns its value.- Throws:
IOException
-
visit
Accepts the given visitor.- Throws:
E extends Throwable
-