Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename Tuple -> Pair #125

Merged
merged 1 commit into from
Jun 5, 2020
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 @@ -16,36 +16,36 @@
*/
package dev.rico.core.lang;

import dev.rico.internal.core.lang.DefaultTuple;
import dev.rico.internal.core.lang.DefaultPair;

/**
* Defines a tuple that holds a key-value pair
* Defines a pair that holds a key-value pair.
*
* @param <K> type of the key
* @param <V> type of the value
*/
public interface Tuple<K, V> {
public interface Pair<K, V> {

/**
* Returns the key
* @return the key
*/
K getKey();

/**
* Returns the value
* @return the value
*/
V getValue();

/**
* Generates a new {@link Tuple} based on the given key and value
* @param key the key
* Generates a new {@link Pair} based on the given key and value.
*
* @param key the key
* @param value the value
* @param <A> type of the key
* @param <B> type of the value
* @return the tuple
* @param <A> type of the key
* @param <B> type of the value
* @return the pair
*/
static <A, B> Tuple<A, B> of(A key, B value) {
return new DefaultTuple<>(key, value);
static <A, B> Pair<A, B> of(A key, B value) {
return new DefaultPair<>(key, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
/**
* Defines a key-value pair both of which are strings
*/
public interface StringPair extends Tuple<String, String> {
public interface StringPair extends Pair<String, String> {

/**
* Generates a new {@link StringPair} based on the given key and value
* Generates a new {@link StringPair} based on the given key and value.
*
* @param key the key
* @param value the value
* @return the pair
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
*/
package dev.rico.internal.core.lang;

import dev.rico.core.lang.Tuple;
import dev.rico.core.lang.Pair;

import java.util.Objects;

/**
* Default implementation of {@link Tuple}
* Default implementation of {@link Pair}
* @param <K> type of the key
* @param <V> type of the value
*/
public class DefaultTuple<K, V> implements Tuple<K, V> {
public class DefaultPair<K, V> implements Pair<K, V> {

private final K key;

private final V value;

public DefaultTuple(final K key, final V value) {
public DefaultPair(final K key, final V value) {
this.key = key;
this.value = value;
}
Expand All @@ -48,7 +48,7 @@ public V getValue() {
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final DefaultTuple<?, ?> tuple = (DefaultTuple<?, ?>) o;
final DefaultPair<?, ?> tuple = (DefaultPair<?, ?>) o;
return Objects.equals(key, tuple.key) &&
Objects.equals(value, tuple.value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import dev.rico.core.lang.StringPair;

/**
* Default implementation of {@link StringPair}
* Default implementation of {@link StringPair}.
*/
public class DefaultStringPair extends DefaultTuple<String, String> implements StringPair {
public class DefaultStringPair extends DefaultPair<String, String> implements StringPair {
public DefaultStringPair(String key, String value) {
super(key, value);
}
Expand Down