Coverage Report - org.codehaus.plexus.metadata.ann.Ann
 
Classes in this File Line Coverage Branch Coverage Complexity
Ann
90 %
9/10
N/A
1
 
 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.lang.reflect.Proxy;
 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 Ann {
 29  
 
 30  
   private String desc;
 31  4
   private Map<String, Object> params = new LinkedHashMap<String, Object>();
 32  
   
 33  4
   public Ann(String desc) {
 34  4
     this.desc = desc;
 35  4
   }
 36  
 
 37  
   public void addParam(String name, Object value) {
 38  7
     params.put(name, value);
 39  7
   }
 40  
   
 41  
   public String getDesc() {
 42  4
     return desc;
 43  
   }
 44  
   
 45  
   public String getType() {
 46  0
     return Type.getType(desc).getClassName();
 47  
   }
 48  
 
 49  
   public Map<String, Object> getParams() {
 50  22
     return params;
 51  
   }
 52  
 
 53  
   @SuppressWarnings("unchecked")
 54  
   public <T> T getAnnotation(Class<T> c, ClassLoader cl) {
 55  4
     return (T) Proxy.newProxyInstance(Ann.class.getClassLoader(), new Class[] { c }, //
 56  
         new AnnInvocationHandler(this, cl, c));
 57  
   }
 58  
   
 59  
 }