MCPcopy Create free account
hub / github.com/cbeust/jcommander / Parameterized

Class Parameterized

src/main/java/com/beust/jcommander/Parameterized.java:14–359  ·  view source on GitHub ↗

Encapsulate a field or a method annotated with @Parameter or @DynamicParameter

Source from the content-addressed store, hash-verified

12 * Encapsulate a field or a method annotated with @Parameter or @DynamicParameter
13 */
14public class Parameterized {
15
16 // Either a method or a field
17 private Field field;
18 private Method method;
19 private Method getter;
20
21 // Either of these two
22 private WrappedParameter wrappedParameter;
23 private ParametersDelegate parametersDelegate;
24
25 public Parameterized(WrappedParameter wp, ParametersDelegate pd,
26 Field field, Method method) {
27 wrappedParameter = wp;
28 this.method = method;
29 this.field = field;
30 if (this.field != null) {
31 if(pd == null) {
32 setFieldAccessible(this.field);
33 } else {
34 setFieldAccessibleWithoutFinalCheck(this.field);
35 }
36 }
37 parametersDelegate = pd;
38 }
39
40 /**
41 * Recursive handler for describing the set of classes while
42 * using the setOfClasses parameter as a collector
43 *
44 * @param inputClass the class to analyze
45 * @param setOfClasses the set collector to collect the results
46 */
47 private static void describeClassTree(Class<?> inputClass, Set<Class<?>> setOfClasses) {
48 // can't map null class
49 if(inputClass == null) {
50 return;
51 }
52
53 // don't further analyze a class that has been analyzed already
54 if(Object.class.equals(inputClass) || setOfClasses.contains(inputClass)) {
55 return;
56 }
57
58 // add to analysis set
59 setOfClasses.add(inputClass);
60
61 // perform super class analysis
62 describeClassTree(inputClass.getSuperclass(), setOfClasses);
63
64 // perform analysis on interfaces
65 for(Class<?> hasInterface : inputClass.getInterfaces()) {
66 describeClassTree(hasInterface, setOfClasses);
67 }
68 }
69
70 /**
71 * Given an object return the set of classes that it extends

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…