Class Reference<T>
java.lang.Object
org.tentackle.trip.Reference<T>
- Type Parameters:
T- the type of the de-duplicatable object
A reference to a de-duplicatable object.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets the referenced object.intGets the reference id.inthashCode()booleanReturns whether the object content follows this reference.booleanisSender()Checks if this is a reference from the sender.booleanisSent()Checks if the reference has been sent.voidMarks the reference as received and the object's content read.voidmarkSent()Marks the reference as sent.static <T> Reference<T> read(TripStream stream, OpCode opCode) Reads a reference from the given stream.voidsend(TripStream stream) Sends the reference to the given stream.voidSets the referenced object.toString()
-
Constructor Details
-
Reference
public Reference(int referenceId, boolean sent, boolean isSender) Creates a new reference.- Parameters:
referenceId- the reference id, starting from 0sent- true if already sent, false if the object content follows in the streamisSender- true if this is a reference from the sender, false if from the receiver
-
Reference
public Reference(int referenceId) Creates an unsent sender reference.- Parameters:
referenceId- the reference id, starting from 0
-
-
Method Details
-
getReferenceId
public int getReferenceId()Gets the reference id.- Returns:
- the reference id, starting from 0
-
isSender
public boolean isSender()Checks if this is a reference from the sender.- Returns:
- true if this is a reference from the sender, false if from the receiver
-
isSent
public boolean isSent()Checks if the reference has been sent.- Returns:
- true if already sent, false if the object content follows in the stream
-
getObject
-
setObject
Sets the referenced object.- Parameters:
object- the referenced object
-
send
Sends the reference to the given stream.- Parameters:
stream- the stream to write to
-
markSent
public void markSent()Marks the reference as sent. -
markReceived
public void markReceived()Marks the reference as received and the object's content read. -
isObjectFollowing
public boolean isObjectFollowing()Returns whether the object content follows this reference.- Returns:
- true if the object content follows this reference
-
read
Reads a reference from the given stream.- Parameters:
stream- the stream to read fromopCode- the op code (already read from the stream)- Returns:
- the reference
-
equals
-
hashCode
-
toString
-