package de.dhbwstuttgart.util;

import java.util.Objects;
import java.util.Optional;

public class Pair<T, T1> {
    private final T key;
    private final T1 value;

    public Pair(T a, T1 b) {
        this.value = b;
        this.key = a;
    }

    public Optional<T1> getValue() {
        return Optional.of(value);
    }

    public T getKey() {
        return key;
    }
    
    public String toString() {
    	return "(" + key.toString() + "," + value.toString() + ")\n";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair<?, ?> pair = (Pair<?, ?>) o;
        return Objects.equals(key, pair.key) && Objects.equals(value, pair.value);
    }

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