Home | History | Annotate | Download | only in media
      1 /*
      2  * Copyright (C) 2009 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.cooliris.media;
     18 
     19 /**
     20  * A pair of objects. Mostly auto-generated by Eclipse.
     21  */
     22 public class Pair<S, T> {
     23     public final S first;
     24     public final T second;
     25 
     26     public Pair(S first, T second) {
     27         this.first = first;
     28         this.second = second;
     29     }
     30 
     31     public static <S, T> Pair<S, T> create(S first, T second) {
     32         return new Pair<S, T>(first, second);
     33     }
     34 
     35     @Override
     36     public int hashCode() {
     37         final int PRIME = 31;
     38         int result = 1;
     39         result = PRIME * result + ((first == null) ? 0 : first.hashCode());
     40         result = PRIME * result + ((second == null) ? 0 : second.hashCode());
     41         return result;
     42     }
     43 
     44     @SuppressWarnings("unchecked")
     45     @Override
     46     public boolean equals(Object obj) {
     47         if (this == obj) {
     48             return true;
     49         }
     50         if (obj == null) {
     51             return false;
     52         }
     53         if (getClass() != obj.getClass()) {
     54             return false;
     55         }
     56         final Pair<S, T> other = (Pair) obj;
     57         if (first == null && other.first != null) {
     58             return false;
     59         } else if (!first.equals(other.first)) {
     60             return false;
     61         }
     62         if (second == null && other.second != null) {
     63             return false;
     64         } else if (!second.equals(other.second)) {
     65             return false;
     66         }
     67         return true;
     68     }
     69 
     70 }
     71