This project has retired. For details please refer to its Attic page.
Source code
001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.reef.io;
020
021import org.apache.reef.annotations.Unstable;
022
023// TODO: Document
024@Unstable
025public final class Tuple<K, V> {
026  private final K k;
027  private final V v;
028
029  public Tuple(final K k, final V v) {
030    this.k = k;
031    this.v = v;
032  }
033
034  public K getKey() {
035    return k;
036  }
037
038  public V getValue() {
039    return v;
040  }
041
042  @Override
043  public boolean equals(final Object o) {
044    if (this == o) return true;
045    if (o == null || getClass() != o.getClass()) return false;
046
047    final Tuple tuple = (Tuple) o;
048
049    if (!k.equals(tuple.k)) return false;
050    if (!v.equals(tuple.v)) return false;
051
052    return true;
053  }
054
055  @Override
056  public int hashCode() {
057    int result = k.hashCode();
058    result = 31 * result + v.hashCode();
059    return result;
060  }
061
062  @Override
063  public String toString() {
064    return "(" + getKey() + "," + getValue() + ")";
065  }
066
067}