Java tutorial
/* * Copyright (C) 2015 QAware GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.qaware.chronix.importer.csv; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; /** * Created by f.lautenschlager on 05.05.2015. */ public final class Pair<T, R> { private final T first; private final R second; public static <T, R> Pair<T, R> of(T first, R second) { return new Pair<>(first, second); } private Pair(T first, R second) { this.first = first; this.second = second; } public T getFirst() { return first; } public R getSecond() { return second; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pair<?, ?> pair = (Pair<?, ?>) o; return new EqualsBuilder().append(first, pair.first).append(second, pair.second).isEquals(); } @Override public int hashCode() { return new HashCodeBuilder(17, 37).append(first).append(second).toHashCode(); } @Override public String toString() { return "Pair{" + "first=" + first + ", second=" + second + '}'; } }