org.rapidpm.frp.model.serial.Pair Maven / Gradle / Ivy
Show all versions of rapidpm-functional-reactive Show documentation
/**
* Copyright © 2017 Sven Ruppert ([email protected])
*
* 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 org.rapidpm.frp.model.serial;
import java.io.Serializable;
import java.util.Objects;
/**
* Copyright (C) 2010 RapidPM
* 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.
*
* Created by RapidPM - Team on 10.12.16.
*
* @author svenruppert
* @version $Id: $Id
*/
public class Pair implements Serializable {
private T1 t1;
private T2 t2;
/**
* Constructor for Pair.
*
* @param t1 a T1 object.
* @param t2 a T2 object.
*/
public Pair(final T1 t1, final T2 t2) {
this.t1 = t1;
this.t2 = t2;
}
/**
* Getter for the field t1
.
*
* @return a T1 object.
*/
public T1 getT1() {
return t1;
}
/**
* Getter for the field t2
.
*
* @return a T2 object.
*/
public T2 getT2() {
return t2;
}
/** {@inheritDoc} */
@Override
public String toString() {
return "Pair{" +
"t1=" + t1 +
", t2=" + t2 +
'}';
}
/** {@inheritDoc} */
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (! (o instanceof Pair)) return false;
final Pair, ?> pair = (Pair, ?>) o;
return Objects.equals(t1, pair.t1) &&
Objects.equals(t2, pair.t2);
}
/** {@inheritDoc} */
@Override
public int hashCode() {
return Objects.hash(t1, t2);
}
/**
* next.
*
* @param a a T1 object.
* @param b a T2 object.
* @param a T1 object.
* @param a T2 object.
* @return a {@link org.rapidpm.frp.model.serial.Pair} object.
*/
public static Pair next(T1 a, T2 b) {
return new Pair<>(a, b);
}
}