Map<Signature, ConstructorD<T>> getConstructors(BeanD<T> parent) { final Map<Signature, MetadataBuilder.ForExecutable<Constructor<? extends T>>> ctorBuilders = beanBuilder.getConstructors(meta); if (ctorBuilders.isEmpty()) { return Collections.emptyMap(); } final Map<Signature, ConstructorD<T>> result = new LinkedHashMap<>(); ctorBuilders.forEach((sig, builder) -> { final Constructor<?> c = Reflection.getDeclaredConstructor(meta.getHost(), sig.getParameterTypes()); @SuppressWarnings({ "unchecked", "rawtypes" }) final Meta.ForConstructor<T> metaCtor = (Meta.ForConstructor) new Meta.ForConstructor<>(c); final ConstructorD<T> descriptor = new ConstructorD<>(new MetadataReader.ForConstructor<T>(metaCtor, builder), parent); if (DescriptorManager.isConstrained(descriptor)) { result.put(sig, descriptor); } }); return Collections.unmodifiableMap(result); }
Map<Signature, ConstructorD<T>> getConstructors(BeanD<T> parent) { final Map<Signature, MetadataBuilder.ForExecutable<Constructor<? extends T>>> ctorBuilders = beanBuilder.getConstructors(meta); if (ctorBuilders.isEmpty()) { return Collections.emptyMap(); } final Map<Signature, ConstructorD<T>> result = new LinkedHashMap<>(); ctorBuilders.forEach((sig, builder) -> { final Constructor<?> c = Reflection.getDeclaredConstructor(meta.getHost(), sig.getParameterTypes()); @SuppressWarnings({ "unchecked", "rawtypes" }) final Meta.ForConstructor<T> metaCtor = (Meta.ForConstructor) new Meta.ForConstructor<>(c); final ConstructorD<T> descriptor = new ConstructorD<>(new MetadataReader.ForConstructor<T>(metaCtor, builder), parent); if (DescriptorManager.isConstrained(descriptor)) { result.put(sig, descriptor); } }); return Collections.unmodifiableMap(result); }
private <T> T newInstance(final Class<T> cls) { final Constructor<T> cons = Reflection.getDeclaredConstructor(cls, ApacheFactoryContext.class); if (cons == null) { throw new ValidationException("Cannot instantiate " + cls); } final boolean mustUnset = Reflection.setAccessible(cons, true); try { return cons.newInstance(validatorContext); } catch (final Exception ex) { throw new ValidationException("Cannot instantiate " + cls, ex); } finally { if (mustUnset) { Reflection.setAccessible(cons, false); } } } }
private <T> T newInstance(final Class<T> cls) { final Constructor<T> cons = Reflection.getDeclaredConstructor(cls, ApacheFactoryContext.class); if (cons == null) { throw new ValidationException("Cannot instantiate " + cls); } final boolean mustUnset = Reflection.setAccessible(cons, true); try { return cons.newInstance(validatorContext); } catch (final Exception ex) { throw new ValidationException("Cannot instantiate " + cls, ex); } finally { if (mustUnset) { Reflection.setAccessible(cons, false); } } } }