summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/types/Formatted.java
blob: 662ab2df7fbd4855f269c403f48c79dc360eca3f (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
package com.mapbox.mapboxsdk.style.types;

import android.support.annotation.Keep;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;

import java.util.Arrays;

/**
 * Represents a string broken into sections annotated with separate formatting options.
 *
 * @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#types-formatted">Style specification</a>
 */
@Keep
public class Formatted {
  private final FormattedSection[] formattedSections;

  /**
   * Create a new formatted text.
   *
   * @param formattedSections sections with formatting options
   */
  @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
  public Formatted(FormattedSection[] formattedSections) {
    this.formattedSections = formattedSections;
  }

  /**
   * Returns sections with separate formatting options that are a part of this formatted text.
   *
   * @return formatted sections
   */
  public FormattedSection[] getFormattedSections() {
    return formattedSections;
  }

  @Override
  public boolean equals(@Nullable Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    Formatted formatted = (Formatted) o;

    return Arrays.equals(formattedSections, formatted.formattedSections);
  }

  @Override
  public int hashCode() {
    return Arrays.hashCode(formattedSections);
  }
}