Clover Coverage Report - FEST Reflection 1.2
Coverage timestamp: Tue Nov 24 2009 20:12:25 PST
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
6   74   5   1.5
2   20   0.83   4
4     1.25  
1    
 
  StaticMethodReturnTypeRef       Line # 40 6 0% 5 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Jan 25, 2009
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5    * the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10    * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11    * specific language governing permissions and limitations under the License.
12    *
13    * Copyright @2009 the original author or authors.
14    */
15    package org.fest.reflect.method;
16   
17    import static org.fest.reflect.method.Invoker.newInvoker;
18    import static org.fest.reflect.method.StaticMethodParameterTypes.newParameterTypes;
19   
20    import org.fest.reflect.reference.TypeRef;
21   
22    /**
23    * Understands the return type of the static method to invoke.
24    * <p>
25    * The following is an example of proper usage of this class:
26    * <pre>
27    * // Equivalent to call 'Jedi.getCommonPowers()'
28    * List&lt;String&gt; powers = {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("getCommonPowers").{@link StaticMethodName#withReturnType(TypeRef) withReturnType}(new {@link TypeRef TypeRef}&lt;List&lt;String&gt;&gt;() {})
29    * .{@link StaticMethodReturnTypeRef#in(Class) in}(Jedi.class)
30    * .{@link Invoker#invoke(Object...) invoke}();
31    * </pre>
32    * </p>
33    *
34    * @param <T> the generic type of the static method's return type.
35    *
36    * @author Alex Ruiz
37    *
38    * @since 1.1
39    */
 
40    public class StaticMethodReturnTypeRef<T> {
41   
 
42  3 toggle static <T> StaticMethodReturnTypeRef<T> newReturnTypeRef(String name, TypeRef<T> type) {
43  3 if (type == null)
44  1 throw new NullPointerException("The return type reference of the static method to access should not be null");
45  2 return new StaticMethodReturnTypeRef<T>(name);
46    }
47   
48    private final String name;
49   
 
50  2 toggle private StaticMethodReturnTypeRef(String name) {
51  2 this.name = name;
52    }
53   
54    /**
55    * Creates a new method invoker.
56    * @param target the object containing the method to invoke.
57    * @return the created method invoker.
58    * @throws NullPointerException if the given target is <code>null</code>.
59    */
 
60  1 toggle public Invoker<T> in(Class<?> target) {
61  1 return newInvoker(name, target);
62    }
63   
64    /**
65    * Specifies the parameter types of the static method to invoke. This method call is optional if the method to invoke
66    * does not take arguments.
67    * @param parameterTypes the parameter types of the method to invoke.
68    * @return the created parameter types holder.
69    * @throws NullPointerException if the array of parameter types is <code>null</code>.
70    */
 
71  1 toggle public StaticMethodParameterTypes<T> withParameterTypes(Class<?>... parameterTypes) {
72  1 return newParameterTypes(name, parameterTypes);
73    }
74    }