# Discriminator

public final class **Discriminator** extends [Object](https://developer.android.com/reference/java/lang/Object.html)  
implements [Parcelable](https://developer.android.com/reference/android/os/Parcelable.html) 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

From interface android.os.Parcelable

|---|---|---|
| int | CONTENTS_FILE_DESCRIPTOR |   |
| int | PARCELABLE_STABILITY_LOCAL |   |
| int | PARCELABLE_STABILITY_VINTF |   |
| int | PARCELABLE_WRITE_RETURN_VALUE |   |

### Public Method Summary

|---|---|
| boolean | [equals](https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator#equals(java.lang.Object))([Object](https://developer.android.com/reference/java/lang/Object.html) other) |
| static [Discriminator](https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator) | [forLongValue](https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator#forLongValue(int))(int longDiscriminator) Creates a new `https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator` representing a full 12-bit discriminator (such as for a QR code). |
| static [Discriminator](https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator) | [forShortValue](https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator#forShortValue(int))(int shortDiscriminator) Creates a new `https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator` representing an abbreviated value (such as for a manual pairing code). |
| int | [getValue](https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator#getValue())() Returns the value of the discriminator. |
| int | [hashCode](https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator#hashCode())() |
| boolean | [matches](https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator#matches(com.google.android.gms.home.matter.common.Discriminator))([Discriminator](https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator) other) Returns true if the discriminator is a match for another discriminator. |
| [String](https://developer.android.com/reference/java/lang/String.html) | [toString](https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator#toString())() |
| void | [writeToParcel](https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator#writeToParcel(android.os.Parcel,%20int))([Parcel](https://developer.android.com/reference/android/os/Parcel.html) dest, int flags) |

### Inherited Method Summary

From class java.lang.Object

|---|---|
| [Object](https://developer.android.com/reference/java/lang/Object.html) | clone() |
| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object.html) arg0) |
| void | finalize() |
| final [Class](https://developer.android.com/reference/java/lang/Class.html)\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

From interface android.os.Parcelable

|---|---|
| abstract int | describeContents() |
| abstract void | writeToParcel([Parcel](https://developer.android.com/reference/android/os/Parcel.html) arg0, int arg1) |

## Public Methods

#### public boolean **equals** ([Object](https://developer.android.com/reference/java/lang/Object.html) other)

#### public static [Discriminator](https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator)
**forLongValue** (int longDiscriminator)

Creates a new `https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator`
representing a full 12-bit discriminator (such as for a QR code).

##### Parameters

| longDiscriminator | the 12-bit discriminator value |
|---|---|

##### Throws

| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | if the given value is negative, or greater than 12 bits |
|---|---|

#### public static [Discriminator](https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator)
**forShortValue** (int shortDiscriminator)

Creates a new `https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/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
`https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator#matches(com.google.android.gms.home.matter.common.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](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | 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](https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/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 `https://developers.home.google.com/android/reference/com/google/android/gms/home/matter/common/Discriminator#equals(java.lang.Object)` which does not incorporate the mask into the equality
test.

##### Parameters

| other | the discriminator to compare to |
|---|---|

#### public [String](https://developer.android.com/reference/java/lang/String.html) **toString** ()

#### public void **writeToParcel** ([Parcel](https://developer.android.com/reference/android/os/Parcel.html) dest, int flags)