Package io.crums.model.hashing
Interface Entity
- All Known Implementing Classes:
Construct
public interface Entity
Every object in our model is an entity.
-
Method Summary
Modifier and Type Method Description java.nio.ByteBuffer
bytes()
Returns the entity's state as a string of bytes.default java.lang.String
bytesHex()
Returns bytes() as a hexadecimal string.boolean
delimited()
Determines if the text representation of the instance is self-delimiting.default boolean
equals(Entity entity)
Equality semantics is governed by bytes().java.lang.CharSequence
toText()
Returns a parseable representation of the entity.
-
Method Details
-
delimited
boolean delimited()Determines if the text representation of the instance is self-delimiting. This figures when deciding whether to bracket (group) entities in, for example, a binary operation. -
bytes
java.nio.ByteBuffer bytes()Returns the entity's state as a string of bytes. Depending on the entity type, this may involve a computation.- Returns:
- a read-only view of the instance's bytes.
-
toText
java.lang.CharSequence toText()Returns a parseable representation of the entity. -
bytesHex
default java.lang.String bytesHex()Returns bytes() as a hexadecimal string. -
equals
Equality semantics is governed by bytes(). Implementations override to exploit logical shortcuts if computing bytes() is expensive.
Independence From Object::equals
Note this method is generally not consistent with Object.equals(Object) (and therefore not consistent with #hashCode() either).
- Parameters:
entity
- non-null
-