Represents a Matter discriminator.
A discriminator may either be a long discriminator (12 bits) or a short discriminator (4 bits). For instance, a manual pairing code specifies only a short discriminator, which provides less uniqueness than the long discriminator provided in the QR code or NFC tag data.
Inherited Constant Summary
Public Method Summary
boolean | |
static Discriminator |
forLongValue(int longDiscriminator)
Creates a new
Discriminator representing a full 12-bit discriminator (such as for
a QR code).
|
static Discriminator |
forShortValue(int shortDiscriminator)
Creates a new
Discriminator representing an abbreviated value (such as for a
manual pairing code).
|
int |
getValue()
Returns the value of the discriminator.
|
int |
hashCode()
|
boolean |
matches(Discriminator
other)
Returns true if the discriminator is a match for another discriminator.
|
String |
toString()
|
void |
writeToParcel(Parcel dest, int
flags)
|
Inherited Method Summary
Public Methods
public boolean equals (Object other)
public static Discriminator forLongValue (int longDiscriminator)
Creates a new Discriminator
representing a full 12-bit discriminator (such as for a QR code).
Parameters
longDiscriminator | the 12-bit discriminator value |
---|
Throws
IllegalArgumentException | if the given value is negative, or greater than 12 bits |
---|
public static Discriminator forShortValue (int shortDiscriminator)
Creates a new Discriminator
representing an abbreviated value (such as for a manual pairing code). For this
discriminator, only the upper 4 bits of the 12-bit value will be used for comparison in
matches(Discriminator)
.
Parameters
shortDiscriminator | the 12-bit discriminator value, of which only the upper 4-bits will be kept. For example, given 0xFAB, the value will be masked to 0xF00) |
---|
Throws
IllegalArgumentException | if the given value is negative, or greater than 12 bits |
---|
public int getValue ()
Returns the value of the discriminator.
public int hashCode ()
public boolean matches (Discriminator other)
Returns true if the discriminator is a match for another discriminator. If both are long discriminators, then this is a simple equality test. However, if one or the other being compared is an abbreviated discriminator, then only the upper 4 bits of the discriminator are considered in the comparison.
Note that this is different behavior from
equals(Object)
which does not incorporate the mask into the equality
test.
Parameters
other | the discriminator to compare to |
---|