All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jamieswhiteshirt.rtree3i.Entry Maven / Gradle / Ivy

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