Coverage Report - org.codehaus.plexus.metadata.ann.AnnMethod
 
Classes in this File Line Coverage Branch Coverage Complexity
AnnMethod
35 %
10/28
0 %
0/8
1,5
 
 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.HashMap;
 20  
 import java.util.LinkedHashMap;
 21  
 import java.util.Map;
 22  
 
 23  
 import org.objectweb.asm.Type;
 24  
 
 25  
 /**
 26  
  * @author Eugene Kuleshov
 27  
  */
 28  
 public class AnnMethod {
 29  
 
 30  
   private final AnnClass owner;
 31  
   private final int access;
 32  
   private final String name;
 33  
   private final String desc;
 34  1
   private Map<String, Ann> anns = new LinkedHashMap<String, Ann>();
 35  1
   private Map<Integer, Map<String, Ann>> paramAnns = new HashMap<Integer, Map<String,Ann>>();
 36  
 
 37  1
   public AnnMethod(AnnClass owner, int access, String name, String desc) {
 38  1
     this.owner = owner;
 39  1
     this.access = access;
 40  1
     this.name = name;
 41  1
     this.desc = desc;
 42  1
   }
 43  
 
 44  
   public int getAccess() {
 45  0
     return access;
 46  
   }
 47  
   
 48  
   public String getName() {
 49  1
     return name;
 50  
   }
 51  
   
 52  
   public String getDesc() {
 53  1
     return desc;
 54  
   }
 55  
 
 56  
   public Map<String, Ann> getAnns() {
 57  0
     return anns;
 58  
   }
 59  
   
 60  
   public Map<Integer, Map<String, Ann>> getParamAnns() {
 61  0
     return paramAnns;
 62  
   }
 63  
   
 64  
   public void addAnn(Ann ann) {
 65  0
     anns.put(ann.getDesc(), ann);
 66  0
   }
 67  
 
 68  
   public void addParamAnn(int parameter, Ann ann) {
 69  0
     Map<String, Ann> anns = paramAnns.get(parameter);
 70  0
     if(anns==null) {
 71  0
       anns = new LinkedHashMap<String, Ann>();
 72  0
       paramAnns.put(parameter, anns);
 73  
     }
 74  0
     anns.put(ann.getDesc(), ann);
 75  0
   }
 76  
   
 77  
   public <T> T getAnnotation(Class<T> c) {
 78  0
     Ann ann = anns.get(Type.getDescriptor(c));
 79  0
     return ann == null ? null : ann.getAnnotation(c, owner.getClassLoader());
 80  
   }
 81  
   
 82  
   public <T> T getParameterAnnotation(int parameter, Class<T> c) {
 83  0
     Map<String, Ann> anns = paramAnns.get(parameter);
 84  0
     if (anns == null) {
 85  0
       return null;
 86  
     }
 87  0
     Ann ann = anns.get(Type.getDescriptor(c));
 88  0
     return ann == null ? null : ann.getAnnotation(c, owner.getClassLoader());
 89  
   }
 90  
 
 91  
 }
 92