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 signature.model.IGenericDeclaration;
     20 import signature.model.ITypeReference;
     21 import signature.model.ITypeVariableDefinition;
     22 import signature.model.util.ModelUtil;
     23 
     24 import java.io.Serializable;
     25 import java.util.List;
     26 
     27 @SuppressWarnings("serial")
     28 public class SigTypeVariableDefinition implements ITypeVariableDefinition,
     29         Serializable {
     30 
     31     private String name;
     32     private IGenericDeclaration genericDeclaration;
     33     private List<ITypeReference> upperBounds = Uninitialized.unset();
     34 
     35     public SigTypeVariableDefinition(String name,
     36             IGenericDeclaration genericDeclaration) {
     37         this.name = name;
     38         this.genericDeclaration = genericDeclaration;
     39     }
     40 
     41     public String getName() {
     42         return name;
     43     }
     44 
     45     public IGenericDeclaration getGenericDeclaration() {
     46         return genericDeclaration;
     47     }
     48 
     49     public List<ITypeReference> getUpperBounds() {
     50         return upperBounds;
     51     }
     52 
     53     public void setUpperBounds(List<ITypeReference> upperBounds) {
     54         this.upperBounds = upperBounds;
     55     }
     56 
     57 
     58     @Override
     59     public String toString() {
     60         StringBuilder builder = new StringBuilder();
     61         builder.append(name);
     62         if (getUpperBounds().size() != 1) {
     63             builder.append(ModelUtil.separate(getUpperBounds(), ", "));
     64         } else {
     65             if (!ModelUtil.isJavaLangObject(getUpperBounds().get(0))) {
     66                 builder.append(getUpperBounds().get(0));
     67             }
     68         }
     69         return builder.toString();
     70     }
     71 
     72 }
     73