Home | History | Annotate | Download | only in assistedinject
      1 /*
      2  * Copyright (C) 2007 Google Inc.
      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.google.inject.assistedinject;
     18 
     19 import com.google.inject.TypeLiteral;
     20 import java.lang.reflect.Type;
     21 import java.util.ArrayList;
     22 import java.util.Arrays;
     23 import java.util.List;
     24 
     25 /**
     26  * A list of {@link TypeLiteral}s to match an injectable Constructor's assited parameter types to
     27  * the corresponding factory method.
     28  *
     29  * @author jmourits (at) google.com (Jerome Mourits)
     30  * @author jessewilson (at) google.com (Jesse Wilson)
     31  */
     32 class ParameterListKey {
     33 
     34   private final List<Type> paramList;
     35 
     36   public ParameterListKey(List<Type> paramList) {
     37     this.paramList = new ArrayList<>(paramList);
     38   }
     39 
     40   public ParameterListKey(Type[] types) {
     41     this(Arrays.asList(types));
     42   }
     43 
     44   @Override
     45   public boolean equals(Object o) {
     46     if (o == this) {
     47       return true;
     48     }
     49     if (!(o instanceof ParameterListKey)) {
     50       return false;
     51     }
     52     ParameterListKey other = (ParameterListKey) o;
     53     return paramList.equals(other.paramList);
     54   }
     55 
     56   @Override
     57   public int hashCode() {
     58     return paramList.hashCode();
     59   }
     60 
     61   @Override
     62   public String toString() {
     63     return paramList.toString();
     64   }
     65 }
     66