ISlot

The slot is a component of the record, which means it belongs to the message. It consists of a slot type and the data it transports. The implementation remains hidden, so that you only have to deal with the ISlot interface. The object itself is put into a form in the slot that can be used to transport it via DataStreams or JSON.

Slots are created via a factory, the ISlotFactory. The ISlotFactor interface is obtained from the service registry.

final ISlotFactory slotFactory = CServiceRegistry.getInstance()
                                                 .getService(ISlotFactory.class);

Type

There is a getter for the type:

@NotNull CSlotType getType();

Value

Another getter fetches the contained data:

Object getValue();

For debug purposes there is another method:

@NotNull String valueToString();

Copy

Slots must be copyable, as message copying is a common task:

ISlot copy();

Transport

For transport, slots must be able to be packed into a DataOutput stream.

void toStream(@NotNull DataOutput aStream) throws IOException;

To be able to read slots from a stream again, the SlotFactory is needed.

Another method for transport is using the JSON format:

@Nullable Object toJson(@NotNull Map<Integer, byte[]> aBinaries);

While in most cases here a string is returned, there are some cases where binary data is returned. Byte arrays, for example, put their value into the map as a byte array, to save as much space as possible. In the JSON variant of the message protocol, binary data is therefore also transported as byte arrays. In the Json format then only the key to the entry in the map is available.

ISlot data comparison

In order to compare the data of slots, there is a special method that does not take into account the type of the slot.

boolean isContentEqualTo(@Nullable Object aValue);

Notes

ISlot support the equals() and hashCode() methods.