return ac.getAnnotated().newInstance(); } catch (Exception e) { Throwable t = e;
protected void _addConstructorMixIns(Class<?> mixin) { MemberKey[] ctorKeys = null; int ctorCount = (_constructors == null) ? 0 : _constructors.size(); for (Constructor<?> ctor : mixin.getDeclaredConstructors()) { if (ctor.getParameterTypes().length == 0) { if (_defaultConstructor != null) { _addMixOvers(ctor, _defaultConstructor, false); } } else { if (ctorKeys == null) { ctorKeys = new MemberKey[ctorCount]; for (int i = 0; i < ctorCount; ++i) { ctorKeys[i] = new MemberKey(_constructors.get(i).getAnnotated()); } } MemberKey key = new MemberKey(ctor); for (int i = 0; i < ctorCount; ++i) { if (!key.equals(ctorKeys[i])) { continue; } _addMixOvers(ctor, _constructors.get(i), true); break; } } } }
/** * Method that can be called to locate a single-arg constructor that * takes specified exact type (will not accept supertype constructors) * * @param argTypes Type(s) of the argument that we are looking for */ public Constructor<?> findSingleArgConstructor(Class<?>... argTypes) { for (AnnotatedConstructor ac : _classInfo.getConstructors()) { // This list is already filtered to only include accessible /* (note: for now this is a redundant check; but in future * that may change; thus leaving here for now) */ if (ac.getParameterCount() == 1) { Class<?> actArg = ac.getParameterClass(0); for (Class<?> expArg : argTypes) { if (expArg == actArg) { return ac.getAnnotated(); } } } } return null; }
if (defaultCtor != null) { if (fixAccess) { ClassUtil.checkAndFixAccess(defaultCtor.getAnnotated());
return ac.getAnnotated().newInstance(); } catch (Exception e) { Throwable t = e;
protected void _addConstructorMixIns(Class<?> mixin) { MemberKey[] ctorKeys = null; int ctorCount = (_constructors == null) ? 0 : _constructors.size(); for (Constructor<?> ctor : mixin.getDeclaredConstructors()) { if (ctor.getParameterTypes().length == 0) { if (_defaultConstructor != null) { _addMixOvers(ctor, _defaultConstructor, false); } } else { if (ctorKeys == null) { ctorKeys = new MemberKey[ctorCount]; for (int i = 0; i < ctorCount; ++i) { ctorKeys[i] = new MemberKey(_constructors.get(i).getAnnotated()); } } MemberKey key = new MemberKey(ctor); for (int i = 0; i < ctorCount; ++i) { if (!key.equals(ctorKeys[i])) { continue; } _addMixOvers(ctor, _constructors.get(i), true); break; } } } }
/** * Method that can be called to locate a single-arg constructor that * takes specified exact type (will not accept supertype constructors) * * @param argTypes Type(s) of the argument that we are looking for */ public Constructor<?> findSingleArgConstructor(Class<?>... argTypes) { for (AnnotatedConstructor ac : _classInfo.getConstructors()) { // This list is already filtered to only include accessible /* (note: for now this is a redundant check; but in future * that may change; thus leaving here for now) */ if (ac.getParameterCount() == 1) { Class<?> actArg = ac.getParameterClass(0); for (Class<?> expArg : argTypes) { if (expArg == actArg) { return ac.getAnnotated(); } } } } return null; }
public NumberBased(Class<?> valueClass, AnnotatedConstructor intCtor, AnnotatedMethod ifm, AnnotatedConstructor longCtor, AnnotatedMethod lfm) { _valueClass = valueClass; _intCtor = (intCtor == null) ? null : intCtor.getAnnotated(); _longCtor = (longCtor == null) ? null : longCtor.getAnnotated(); _intFactoryMethod = (ifm == null) ? null : ifm.getAnnotated(); _longFactoryMethod = (lfm == null) ? null : lfm.getAnnotated(); }
protected AnnotatedConstructor verifyNonDup(AnnotatedConstructor newOne, AnnotatedConstructor oldOne, String type) { if (oldOne != null) { throw new IllegalArgumentException("Conflicting "+type+" constructors: already had "+oldOne+", encountered "+newOne); } if (_canFixAccess) { ClassUtil.checkAndFixAccess(newOne.getAnnotated()); } return newOne; }
public StringBased(Class<?> valueClass, AnnotatedConstructor ctor, AnnotatedMethod factoryMethod) { _valueClass = valueClass; _ctor = (ctor == null) ? null : ctor.getAnnotated(); _factoryMethod = (factoryMethod == null) ? null : factoryMethod.getAnnotated(); }
protected AnnotatedConstructor verifyNonDup(AnnotatedConstructor newOne, AnnotatedConstructor oldOne, String type) { if (oldOne != null) { throw new IllegalArgumentException("Conflicting "+type+" constructors: already had "+oldOne+", encountered "+newOne); } if (_canFixAccess) { ClassUtil.checkAndFixAccess(newOne.getAnnotated()); } return newOne; }
public StringBased(Class<?> valueClass, AnnotatedConstructor ctor, AnnotatedMethod factoryMethod) { _valueClass = valueClass; _ctor = (ctor == null) ? null : ctor.getAnnotated(); _factoryMethod = (factoryMethod == null) ? null : factoryMethod.getAnnotated(); }
public NumberBased(Class<?> valueClass, AnnotatedConstructor intCtor, AnnotatedMethod ifm, AnnotatedConstructor longCtor, AnnotatedMethod lfm) { _valueClass = valueClass; _intCtor = (intCtor == null) ? null : intCtor.getAnnotated(); _longCtor = (longCtor == null) ? null : longCtor.getAnnotated(); _intFactoryMethod = (ifm == null) ? null : ifm.getAnnotated(); _longFactoryMethod = (lfm == null) ? null : lfm.getAnnotated(); }
/** * Method that will locate the no-arg constructor for this class, * if it has one, and that constructor has not been marked as * ignorable. * Method will also ensure that the constructor is accessible. */ public Constructor<?> findDefaultConstructor() { AnnotatedConstructor ac = _classInfo.getDefaultConstructor(); if (ac == null) { return null; } return ac.getAnnotated(); }
/** * Method that will locate the no-arg constructor for this class, * if it has one, and that constructor has not been marked as * ignorable. * Method will also ensure that the constructor is accessible. */ public Constructor<?> findDefaultConstructor() { AnnotatedConstructor ac = _classInfo.getDefaultConstructor(); if (ac == null) { return null; } return ac.getAnnotated(); }
if (defaultCtor != null) { if (fixAccess) { ClassUtil.checkAndFixAccess(defaultCtor.getAnnotated());
public PropertyBased(AnnotatedConstructor ctor, SettableBeanProperty[] ctorProps, AnnotatedMethod factory, SettableBeanProperty[] factoryProps) { // We will only use one: and constructor has precedence over factory SettableBeanProperty[] props; if (ctor != null) { _ctor = ctor.getAnnotated(); _factoryMethod = null; props = ctorProps; } else if (factory != null) { _ctor = null; _factoryMethod = factory.getAnnotated(); props = factoryProps; } else { throw new IllegalArgumentException("Internal error: neither delegating constructor nor factory method passed"); } _properties = new HashMap<String, SettableBeanProperty>(); for (SettableBeanProperty prop : props) { _properties.put(prop.getPropertyName(), prop); } }
public Delegating(AnnotatedConstructor ctor, AnnotatedMethod factory) { if (ctor != null) { _ctor = ctor.getAnnotated(); _factoryMethod = null; _valueType = TypeFactory.type(ctor.getParameterType(0)); } else if (factory != null) { _ctor = null; _factoryMethod = factory.getAnnotated(); _valueType = TypeFactory.type(factory.getParameterType(0)); } else { throw new IllegalArgumentException("Internal error: neither delegating constructor nor factory method passed"); } }
/** * Method that can be called to locate a single-arg constructor that * takes specified exact type (will not accept supertype constructors) * * @param argTypes Type(s) of the argument that we are looking for */ public Constructor<?> findSingleArgConstructor(Class<?>... argTypes) { for (AnnotatedConstructor ac : _classInfo.getConstructors()) { // This list is already filtered to only include accessible /* (note: for now this is a redundant check; but in future * that may change; thus leaving here for now) */ if (ac.getParameterCount() == 1) { Class<?> actArg = ac.getParameterClass(0); for (Class<?> expArg : argTypes) { if (expArg == actArg) { return ac.getAnnotated(); } } } } return null; }
public Delegating(BasicBeanDescription beanDesc, AnnotatedConstructor ctor, AnnotatedMethod factory) { TypeBindings bindings = beanDesc.bindingsForBeanType(); if (ctor != null) { _creator = ctor; _ctor = ctor.getAnnotated(); _factoryMethod = null; _valueType = bindings.resolveType(ctor.getParameterType(0)); } else if (factory != null) { _creator = factory; _ctor = null; _factoryMethod = factory.getAnnotated(); _valueType = bindings.resolveType(factory.getParameterType(0)); } else { throw new IllegalArgumentException("Internal error: neither delegating constructor nor factory method passed"); } }