
com.jamieswhiteshirt.rtree3i.Entry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rtree-3i-lite Show documentation
Show all versions of rtree-3i-lite Show documentation
Immutable map applying a spatial index to keys based on R-Trees
The newest version!
package com.jamieswhiteshirt.rtree3i;
import com.google.common.base.Preconditions;
import java.util.Objects;
/**
* An entry in an R-tree.
*
* @param the key type
* @param the value type
*/
public final class Entry {
private final K key;
private final V value;
private Entry(K key, V value) {
Preconditions.checkNotNull(key);
this.key = key;
this.value = value;
}
/**
* Returns an entry with the specified key and value.
* @param key key of the entry
* @param value value of the entry
* @param key type
* @param value type
* @return an entry with the specified key and value
*/
public static Entry of(K key, V value) {
return new Entry<>(key, value);
}
/**
* Returns the key of this {@link Entry}.
*
* @return the entry key
*/
public K getKey() {
return key;
}
/**
* Returns the value wrapped by this {@link Entry}.
*
* @return the entry value
*/
public V getValue() {
return value;
}
@Override
public String toString() {
return "Entry{" +
"key=" + key +
", value=" + value +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Entry, ?> entry = (Entry, ?>) o;
return Objects.equals(key, entry.key) &&
Objects.equals(value, entry.value);
}
@Override
public int hashCode() {
return Objects.hash(key, value);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy