Class ColorId
- java.lang.Object
-
- com.google.javascript.jscomp.colors.ColorId
-
- All Implemented Interfaces:
java.io.Serializable
@Immutable public final class ColorId extends java.lang.Object implements java.io.SerializableA probablistically unique ID for a Color.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:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.protobuf.ByteStringasByteString()booleanequals(java.lang.Object x)static ColorIdfromAscii(java.lang.String str)static ColorIdfromBytes(byte[] bytes)static ColorIdfromBytes(com.google.protobuf.ByteString bytes)static ColorIdfromUnsigned(byte x)static ColorIdfromUnsigned(int x)static ColorIdfromUnsigned(long x)inthashCode()java.lang.StringtoString()static ColorIdunion(java.util.Set<ColorId> ids)Defines how IDs for unions are combined.
-
-
-
Method Detail
-
fromUnsigned
public static ColorId fromUnsigned(long x)
-
fromUnsigned
public static ColorId fromUnsigned(int x)
-
fromUnsigned
public static ColorId fromUnsigned(byte x)
-
fromBytes
public static ColorId fromBytes(com.google.protobuf.ByteString bytes)
-
fromBytes
public static ColorId fromBytes(byte[] bytes)
-
fromAscii
public static ColorId fromAscii(java.lang.String str)
-
union
public static ColorId union(java.util.Set<ColorId> ids)
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
public boolean equals(java.lang.Object x)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
asByteString
public com.google.protobuf.ByteString asByteString()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-