Skip to content

Commit

Permalink
Added methods (#978)
Browse files Browse the repository at this point in the history
Signed-off-by: dhoard <[email protected]>
  • Loading branch information
dhoard authored Jul 30, 2024
1 parent d567081 commit ac0a930
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.prometheus.metrics.model.snapshots;

import java.util.Objects;

/**
* Utility for iterating over {@link Labels}.
*/
Expand All @@ -16,6 +18,7 @@ public Label(String name, String value) {
public String getName() {
return name;
}

public String getValue() {
return value;
}
Expand All @@ -25,4 +28,25 @@ public int compareTo(Label other) {
int nameCompare = name.compareTo(other.name);
return nameCompare != 0 ? nameCompare : value.compareTo(other.value);
}

@Override
public String toString() {
return "Label{" +
"name='" + name + '\'' +
", value='" + value + '\'' +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Label label = (Label) o;
return Objects.equals(name, label.name) && Objects.equals(value, label.value);
}

@Override
public int hashCode() {
return Objects.hash(name, value);
}
}

0 comments on commit ac0a930

Please sign in to comment.