Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.apache.beam.sdk.util;

import java.util.Objects;
import javax.annotation.Nullable;
import org.apache.beam.sdk.annotations.Internal;

/**
Expand Down Expand Up @@ -47,4 +49,26 @@ public long getWeight() {
public T getValue() {
return value;
}

@Override
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
if (!(o instanceof WeightedValue)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check for null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null instanceof X is always false so checking for null is redundant.

return false;
}
WeightedValue<?> that = (WeightedValue<?>) o;
return weight == that.weight && Objects.equals(value, that.value);
}

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

@Override
public String toString() {
return "WeightedValue{value=" + value + ", weight=" + weight + "}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,7 @@ interface Shrinkable<V> {

/** Removes the mapping for a key from the cache if it is present. */
void remove(K key);

/** Returns a string containing caching statistics. */
String describeStats();
}
Loading