Class Region

  • All Implemented Interfaces:
    Parcelable, Serializable

    public class Region
    extends Object
    implements Parcelable, Serializable
    This class represents a criteria of fields used to match beacons. The uniqueId field is used to distinguish this Region in the system. When you set up monitoring or ranging based on a Region and later want to stop monitoring or ranging, you must do so by passing a Region object that has the same uniqueId field value. If it doesn't match, you can't cancel the operation. There is no other purpose to this field. The region can be constructed from a multi-part identifier. The first identifier is the most significant, the second the second most significant, etc. When constructing a range, any or all of these identifiers may be set to null, which indicates that they are a wildcard and will match any value.
    See Also:
    Serialized Form
    • Field Detail

      • mBluetoothAddress

        protected final String mBluetoothAddress
      • mUniqueId

        protected final String mUniqueId
    • Constructor Detail

      • Region

        public Region​(String uniqueId,
                      Identifier id1,
                      Identifier id2,
                      Identifier id3)
        Constructs a new Region object to be used for Ranging or Monitoring
        Parameters:
        uniqueId - - A unique identifier used to later cancel Ranging and Monitoring, or change the region being Ranged/Monitored
        id1 - - most significant identifier (can be null)
        id2 - - second most significant identifier (can be null)
        id3 - - third most significant identifier (can be null)
      • Region

        public Region​(String uniqueId,
                      List<Identifier> identifiers)
        Constructs a new Region object to be used for Ranging or Monitoring
        Parameters:
        uniqueId - - A unique identifier used to later cancel Ranging and Monitoring, or change the region being Ranged/Monitored
        identifiers - - list of identifiers for this region
      • Region

        public Region​(String uniqueId,
                      List<Identifier> identifiers,
                      String bluetoothAddress)
        Constructs a new Region object to be used for Ranging or Monitoring
        Parameters:
        uniqueId - - A unique identifier used to later cancel Ranging and Monitoring, or change the region being Ranged/Monitored
        identifiers - - list of identifiers for this region
        bluetoothAddress - - mac address
      • Region

        public Region​(String uniqueId,
                      String bluetoothAddress)
        Constructs a new Region object to be used for Ranging or Monitoring
        Parameters:
        uniqueId - - A unique identifier used to later cancel Ranging and Monitoring, or change the region being Ranged/Monitored
        bluetoothAddress - - mac address used to match beacons
      • Region

        protected Region​(Parcel in)
    • Method Detail

      • getId1

        public Identifier getId1()
        Convenience method to get the first identifier
        Returns:
      • getId2

        public Identifier getId2()
        Convenience method to get the second identifier
        Returns:
      • getId3

        public Identifier getId3()
        Convenience method to get the third identifier
        Returns:
      • getIdentifier

        public Identifier getIdentifier​(int i)
        Returns the 0-indexed identifier Note: IMPORTANT: to get id1, you would call getIdentifier(0);
        Parameters:
        i -
        Returns:
      • getUniqueId

        public String getUniqueId()
        Returns the identifier used to start or stop ranging/monitoring this region when calling the BeaconManager methods.
        Returns:
      • getBluetoothAddress

        public String getBluetoothAddress()
        Returns the mac address used to filter for beacons
      • matchesBeacon

        public boolean matchesBeacon​(Beacon beacon)
        Checks to see if an Beacon object is included in the matching criteria of this Region
        Parameters:
        beacon - the beacon to check to see if it is in the Region
        Returns:
        true if is covered
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • hasSameIdentifiers

        public boolean hasSameIdentifiers​(Region region)
      • clone

        @Deprecated
        public Region clone()
        Deprecated.
        instances of this class are immutable and therefore don't have to be cloned when used in concurrent code.
        Returns a clone of this instance.
        Overrides:
        clone in class Object
        Returns:
        a new instance of this class with the same uniqueId and identifiers