Class ColorId
- All Implemented Interfaces:
LogsGson.Able,Serializable
This is a semantic wrapper around UUID bytes to provide better typing when passing those bytes around. It also hosts some utility methods to ensure consistent byte handling and help with testing/debugging.
If two Colors have the same ID, they should be considered to represent the same "logical" Color, perhaps inferred in different libraries. Ideally, those instances would be reconciled before either Color is instantiated.
IDs have an intentionally unspecified width so that it may expand if needed in the future. For the purposes of comparison, serialization, and display, leading 0s are ignored.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncom.google.protobuf.ByteStringbooleanstatic ColorIdstatic ColorIdfromBytes(byte[] bytes) static ColorIdfromBytes(com.google.protobuf.ByteString bytes) static ColorIdfromUnsigned(byte x) static ColorIdfromUnsigned(int x) static ColorIdfromUnsigned(long x) inthashCode()toString()static ColorIdDefines how IDs for unions are combined.
-
Method Details
-
fromUnsigned
-
fromUnsigned
-
fromUnsigned
-
fromBytes
-
fromBytes
-
fromAscii
-
union
Defines how IDs for unions are combined.Ideally, this function would preserve the algebraic properties of the union operation. However, doing so is difficult (impossible?) while also providing good hashing. Those properties are summarized below.
This method must never be passed IDs of existing unions. Lack of associativity means the result will not be the same as unioning all the IDs simultaneously.
| name | has | example | note | |---------------|-------|-------------------------------|-----------------------------| | associativity | false | f(x, f(y, z)) = f(f(x, y), z) | | | commutativity | true | f(x, y) = f(y, x) | | | idempotence | true | f(x, x, y) = f(x, y) | `ids` is a Set | | identity | true | f(x) = x | singleton unions are banned |
-
equals
-
hashCode
public int hashCode() -
asByteString
public com.google.protobuf.ByteString asByteString() -
toString
-
toLogsGson
- Specified by:
toLogsGsonin interfaceLogsGson.Able
-