Coverage Report - org.codehaus.plexus.metadata.ann.AnnField
 
Classes in this File Line Coverage Branch Coverage Complexity
AnnField
81 %
13/16
100 %
2/2
1,125
 
 1  
 /*
 2  
  * Copyright (C) 2008 the original author or authors.
 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 org.codehaus.plexus.metadata.ann;
 18  
 
 19  
 import java.util.LinkedHashMap;
 20  
 import java.util.Map;
 21  
 
 22  
 import org.objectweb.asm.Type;
 23  
 
 24  
 /**
 25  
  * @author Eugene Kuleshov
 26  
  */
 27  
 public class AnnField {
 28  
 
 29  
   private final AnnClass owner;
 30  
   private final int access;
 31  
   private final String name;
 32  
   private final String desc;
 33  2
   private Map<String, Ann> anns = new LinkedHashMap<String,Ann>();
 34  
   
 35  2
   public AnnField(AnnClass owner, int access, String name, String desc) {
 36  2
     this.owner = owner;
 37  2
     this.access = access;
 38  2
     this.desc = desc;
 39  2
     this.name = name;
 40  2
   }
 41  
 
 42  
   public int getAccess() {
 43  0
     return access;
 44  
   }
 45  
   
 46  
   public String getName() {
 47  4
     return name;
 48  
   }
 49  
   
 50  
   public String getDesc() {
 51  0
     return desc;
 52  
   }
 53  
   
 54  
   public Map<String, Ann> getAnns() {
 55  0
     return anns;
 56  
   }
 57  
   
 58  
   public String getType() {
 59  2
     return Type.getType(desc).getClassName();
 60  
   }
 61  
 
 62  
   public void addAnn(Ann ann) {
 63  3
     anns.put(ann.getDesc(), ann);
 64  3
   }
 65  
   
 66  
   public <T> T getAnnotation(Class<T> c) {
 67  4
     Ann ann = anns.get(Type.getDescriptor(c));
 68  4
     return ann == null ? null : ann.getAnnotation(c, owner.getClassLoader());
 69  
   }
 70  
 
 71  
 }
 72