private MetaConstructor getAccessibleNoArgConstructor(final MetaClass type) { final MetaConstructor noArgConstr = type.getDeclaredConstructor(new MetaClass[0]); if (noArgConstr != null && (noArgConstr.isPublic() || noArgConstr.isProtected())) { return noArgConstr; } else { return null; } }
&& definition.getInstantiationMapping().getMappings().length == 0) { final MetaConstructor defaultConstructor = toMap.getDeclaredConstructor(new Class[0]); if (defaultConstructor == null || !defaultConstructor.isPublic()) { throw new InvalidMappingException("there is no custom mapping or default no-arg constructor to map: "
@Test public void testGetDeclaredConstructorFindsAllConstructors() throws Exception { final MetaClass mc = getMetaClass(HasManyConstructors.class); assertNotNull(mc.getDeclaredConstructor(new Class[0])); assertNotNull(mc.getDeclaredConstructor(new Class[] {int.class})); assertNotNull(mc.getDeclaredConstructor(new Class[] {String.class})); assertNotNull(mc.getDeclaredConstructor(new Class[] {double.class})); }
&& definition.getInstantiationMapping().getMappings().length == 0) { final MetaConstructor defaultConstructor = toMap.getDeclaredConstructor(new Class[0]); if (defaultConstructor == null || !defaultConstructor.isPublic()) { throw new InvalidMappingException("there is no custom mapping or default no-arg constructor to map: "
final MetaConstructor noArgConstructor = type.getDeclaredConstructor(new MetaClass[0]); return noArgConstructor != null && (noArgConstructor.isPublic() || !isJavaScriptObject(type));
private void assignNewObjectWithZeroArgConstructor(final Injectable injectable, final List<Statement> createInstanceStatements) { final MetaConstructor noArgConstr = injectable.getInjectedType().getDeclaredConstructor(new MetaClass[0]); final Object newObjectStmt; if (noArgConstr.isPublic()) { newObjectStmt = newObject(injectable.getInjectedType()); } else { newObjectStmt = controller.exposedConstructorStmt(noArgConstr); } createInstanceStatements.add(declareFinalVariable("instance", injectable.getInjectedType(), newObjectStmt)); }
private boolean isConstructable(final MetaClass type, final List<String> problems) { final boolean explicitlyScoped = getDirectScope(type) != null; final List<MetaConstructor> injectableConstructors = getInjectableConstructors(type); final MetaConstructor noArgConstructor = type.getDeclaredConstructor(new MetaClass[0]);
def.getMappingClass().getDeclaredConstructor(toMerge.getInstantiationMapping().getSignature()) != null) {
def.getMappingClass().getDeclaredConstructor(toMerge.getInstantiationMapping().getSignature()) != null) {
if (bindable.getDeclaredConstructor(new MetaClass[0]) == null || !bindable.getDeclaredConstructor(new MetaClass[0]).isPublic()) { throw new RuntimeException("@Bindable type needs a public default no-arg constructor: " + bindable.getFullyQualifiedName());
if (bindable.getDeclaredConstructor(new MetaClass[0]) == null || !bindable.getDeclaredConstructor(new MetaClass[0]).isPublic()) { throw new RuntimeException("@Bindable type needs a public default no-arg constructor: " + bindable.getFullyQualifiedName());