summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java
blob: b1a05ec4365cd80b3610d0ae9895ff901b5aa74b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.mapbox.mapboxsdk.annotations;

import android.graphics.Bitmap;

import com.mapbox.mapboxsdk.maps.MapView;

/**
 * Icon is the visual representation of a {@link Marker} on a {@link MapView}.
 *
 * @see Marker
 */
public class Icon {
  private Bitmap mBitmap;
  private String mId;

  Icon(String id, Bitmap bitmap) {
    mId = id;
    mBitmap = bitmap;
  }

  /**
   * {@link String} identifier for this {@link Icon}.
   *
   * @return {@link String} identifier for this {@link Icon}.
   */
  public String getId() {
    return mId;
  }

  /**
   * Get the {@link Bitmap} being used for this {@link Icon}.
   *
   * @return The {@link Bitmap} being used for the {@link Icon}.
   */
  public Bitmap getBitmap() {
    return mBitmap;
  }

  /**
   * Compares this {@link Icon} object with another {@link Icon} and determines if they match.
   *
   * @param object Another {@link Icon} to compare with this object.
   * @return True if the {@link Icon} being passed in matches this {@link Icon} object. Else,
   * false.
   */
  @Override
  public boolean equals(Object object) {
    if (this == object) {
      return true;
    }
    if (object == null || getClass() != object.getClass()) {
      return false;
    }

    Icon icon = (Icon) object;

    if (!mBitmap.equals(icon.mBitmap)) {
      return false;
    }
    return mId.equals(icon.mId);
  }

  /**
   * Gives an integer which can be used as the bucket number for storing elements of the set/map.
   * This bucket number is the address of the element inside the set/map. There's no guarantee
   * that this hash value will be consistent between different Java implementations, or even
   * between different execution runs of the same program.
   *
   * @return integer value you can use for storing element.
   */
  @Override
  public int hashCode() {
    int result = 0;
    if (mBitmap != null) {
      result = mBitmap.hashCode();
    }
    if (mId != null) {
      result = 31 * result + mId.hashCode();
    }
    return result;
  }
}