4444
4545import static io .jooby .SneakyThrows .propagate ;
4646
47- public class ValueInjector {
47+ public final class ValueInjector {
4848
4949 private static final String AMBIGUOUS_CONSTRUCTOR =
5050 "Ambiguous constructor found. Expecting a single constructor or only one annotated with "
5151 + Inject .class .getName ();
5252
5353 private static final Object [] NO_ARGS = new Object [0 ];
5454
55- public <T > T inject (Value scope , Class type ) {
55+ public static <T > T inject (Value scope , Class type ) {
5656 return inject (scope , type , type );
5757 }
5858
59- public <T > T inject (Value scope , Type type , Class rawType ) {
59+ public static <T > T inject (Value scope , Type type , Class rawType ) {
6060 try {
6161 Object result = value (scope , rawType , type );
6262 return (T ) result ;
@@ -67,7 +67,7 @@ public <T> T inject(Value scope, Type type, Class rawType) {
6767 }
6868 }
6969
70- private <T > T newInstance (Class <T > type , Value scope )
70+ private static <T > T newInstance (Class <T > type , Value scope )
7171 throws IllegalAccessException , InstantiationException , InvocationTargetException ,
7272 NoSuchMethodException {
7373 Constructor [] constructors = type .getConstructors ();
@@ -83,7 +83,7 @@ private <T> T newInstance(Class<T> type, Value scope)
8383 return (T ) setters (constructor .newInstance (args ), scope , state );
8484 }
8585
86- private Constructor selectConstructor (Constructor [] constructors ) {
86+ private static Constructor selectConstructor (Constructor [] constructors ) {
8787 Constructor result = null ;
8888 if (constructors .length == 1 ) {
8989 result = constructors [0 ];
@@ -107,7 +107,7 @@ private Constructor selectConstructor(Constructor[] constructors) {
107107 return result ;
108108 }
109109
110- private <T > T setters (T newInstance , Value object , Set <Value > skip ) {
110+ private static <T > T setters (T newInstance , Value object , Set <Value > skip ) {
111111 Method [] methods = newInstance .getClass ().getMethods ();
112112 for (Value value : object ) {
113113 if (!skip .contains (value )) {
@@ -134,7 +134,7 @@ private <T> T setters(T newInstance, Value object, Set<Value> skip) {
134134 return newInstance ;
135135 }
136136
137- private Method findMethod (Method [] methods , String name ) {
137+ private static Method findMethod (Method [] methods , String name ) {
138138 for (Method method : methods ) {
139139 if (method .getName ().equals (name ) && method .getParameterCount () == 1 ) {
140140 return method ;
@@ -143,7 +143,7 @@ private Method findMethod(Method[] methods, String name) {
143143 return null ;
144144 }
145145
146- private Object resolve (Value scope , Class type )
146+ private static Object resolve (Value scope , Class type )
147147 throws IllegalAccessException , InvocationTargetException , InstantiationException ,
148148 NoSuchMethodException {
149149 if (scope .isObject () || scope .isSingle ()) {
@@ -159,7 +159,7 @@ private Object resolve(Value scope, Class type)
159159 }
160160 }
161161
162- public Object [] inject (Value scope , Executable method , Consumer <Value > state )
162+ public static Object [] inject (Value scope , Executable method , Consumer <Value > state )
163163 throws IllegalAccessException , InstantiationException , InvocationTargetException ,
164164 NoSuchMethodException {
165165 Parameter [] parameters = method .getParameters ();
@@ -183,7 +183,7 @@ public Object[] inject(Value scope, Executable method, Consumer<Value> state)
183183 return args ;
184184 }
185185
186- private String paramName (Parameter parameter ) {
186+ private static String paramName (Parameter parameter ) {
187187 String name = parameter .getName ();
188188 Named named = parameter .getAnnotation (Named .class );
189189 if (named != null && named .value ().length () > 0 ) {
@@ -265,7 +265,7 @@ public static boolean isSimple(Class rawType, Type type) {
265265 return false ;
266266 }
267267
268- private Object value (Value value , Class rawType , Type type )
268+ private static Object value (Value value , Class rawType , Type type )
269269 throws InvocationTargetException , IllegalAccessException , InstantiationException ,
270270 NoSuchMethodException {
271271 if (value .isMissing () && rawType != Optional .class ) {
@@ -363,7 +363,7 @@ private Object value(Value value, Class rawType, Type type)
363363 return resolve (value , rawType );
364364 }
365365
366- private Collection collection (Value scope , ParameterizedType type , Collection result )
366+ private static Collection collection (Value scope , ParameterizedType type , Collection result )
367367 throws InvocationTargetException , IllegalAccessException , InstantiationException ,
368368 NoSuchMethodException {
369369 Class itemType = $Types .parameterizedType0 (type );
0 commit comments