Home | History | Annotate | Download | only in impl
      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 signature.model.impl;
     18 
     19 import java.io.Serializable;
     20 
     21 import signature.model.IArrayType;
     22 import signature.model.ITypeReference;
     23 
     24 @SuppressWarnings("serial")
     25 public class SigArrayType implements IArrayType, Serializable {
     26     private ITypeReference componentType;
     27 
     28     public SigArrayType(ITypeReference componentType) {
     29         this.componentType = componentType;
     30     }
     31 
     32     public ITypeReference getComponentType() {
     33         return componentType;
     34     }
     35 
     36     @Override
     37     public int hashCode() {
     38         return SigArrayType.hashCode(this);
     39     }
     40 
     41     public static int hashCode(IArrayType type) {
     42         return type.getComponentType().hashCode();
     43     }
     44 
     45     @Override
     46     public boolean equals(Object obj) {
     47         return SigArrayType.equals(this, obj);
     48     }
     49 
     50     public static boolean equals(IArrayType thiz, Object that) {
     51         if (!(that instanceof IArrayType)) {
     52             return false;
     53         }
     54         IArrayType other = (IArrayType) that;
     55         return thiz.getComponentType().equals(other.getComponentType());
     56     }
     57 
     58     @Override
     59     public String toString() {
     60         return SigArrayType.toString(this);
     61     }
     62 
     63     public static String toString(IArrayType type) {
     64         StringBuilder builder = new StringBuilder();
     65         builder.append(type.getComponentType().toString());
     66         builder.append("[]");
     67         return builder.toString();
     68     }
     69 }
     70