public MethodBeanCreator(Method method, String[] parameterNames, Type[] expandedParameterTypes, Class<?> concreteClass) { super(method.getReturnType(), method.getDeclaringClass(), concreteClass, parameterNames, expandedParameterTypes, method.getParameterAnnotations()); if (!Modifier.isStatic(method.getModifiers())) throw new IllegalStateException("Only static methods can be used as creators!"); this._creator = method; if (!_creator.isAccessible()) { _creator.setAccessible(true); } decorate(_creator); }
public Object create(Object... args) { try { // we will handle only static method creators return ofClass.cast(_creator.invoke(null, args)); } catch (IllegalArgumentException e) { throw couldNotCreate(e); } catch (IllegalAccessException e) { throw couldNotCreate(e); } catch (InvocationTargetException e) { throw couldNotCreate(e); } }
public Object create(Object... args) { try { // we will handle only static method creators return ofClass.cast(_creator.invoke(null, args)); } catch (IllegalArgumentException e) { throw couldNotCreate(e); } catch (IllegalAccessException e) { throw couldNotCreate(e); } catch (InvocationTargetException e) { throw couldNotCreate(e); } }
public MethodBeanCreator(Method method, String[] parameterNames, Type[] expandedParameterTypes, Class<?> concreteClass) { super(method.getReturnType(), method.getDeclaringClass(), concreteClass, parameterNames, expandedParameterTypes, method.getParameterAnnotations()); if (!Modifier.isStatic(method.getModifiers())) throw new IllegalStateException("Only static methods can be used as creators!"); this._creator = method; if (!_creator.isAccessible()) { _creator.setAccessible(true); } decorate(_creator); }
public BeanCreator createCreator(Type ofType, Method method, String[] resolvedNames, Genson genson) { return new BeanCreator.MethodBeanCreator(method, resolvedNames, expandTypes( method.getGenericParameterTypes(), ofType), getRawClass(ofType)); }
public BeanCreator createCreator(Type ofType, Method method, String[] resolvedNames, Genson genson) { return new BeanCreator.MethodBeanCreator(method, resolvedNames, expandTypes( method.getGenericParameterTypes(), ofType), getRawClass(ofType)); }