if (remote.isInterface()) {
@Override public ClassDefinitionBuilderInterfaces<T> implementsInterface(final MetaClass clazz) { if (!clazz.isInterface()) { throw new RuntimeException("not an interface: " + clazz.getFullyQualifiedName()); } classDefinition.addInterface(clazz); return this; }
@Override public ClassDefinitionBuilderInterfaces<T> implementsInterface(final MetaClass clazz) { if (!clazz.isInterface()) { throw new RuntimeException("not an interface: " + clazz.getFullyQualifiedName()); } classDefinition.addInterface(clazz); return this; }
/** * @return True iff the given type is an interface extending {@code elemental.html.Element}. */ public static boolean isElementalIface(final MetaClass type) { if (!(type.isInterface() && type.getPackageName().startsWith("elemental."))) { return false; } final Queue<MetaClass> ifaces = new LinkedList<MetaClass>(); ifaces.add(type); while (!ifaces.isEmpty()) { final MetaClass iface = ifaces.poll(); if (iface.getFullyQualifiedName().equals("elemental.dom.Element")) { return true; } else { ifaces.addAll(Arrays.asList(iface.getInterfaces())); } } return false; }
@Override public void callback(final MetaClass type) { if (!type.getFullyQualifiedName().startsWith("java.util")) { if (type.isInterface()) { jsTypeIfaces.add(type); } else if (type.isConcrete() && type.isPublic()) { findJsTypeIfaces(type) .forEach(iface -> { jsTypeIfaces.add(iface); jsTypeIfaceImpls.put(iface, type); }); } } }
/** * @return True iff the given type is an interface extending {@code elemental.html.Element}. */ public static boolean isElementalIface(final MetaClass type) { if (!(type.isInterface() && type.getPackageName().startsWith("elemental."))) { return false; } final Queue<MetaClass> ifaces = new LinkedList<MetaClass>(); ifaces.add(type); while (!ifaces.isEmpty()) { final MetaClass iface = ifaces.poll(); if (iface.getFullyQualifiedName().equals("elemental.dom.Element")) { return true; } else { ifaces.addAll(Arrays.asList(iface.getInterfaces())); } } return false; }
private static boolean validateWildcardSerializable(MetaClass mc) { if (mc.isInterface() || (mc.isAbstract() && !mc.isEnum())) { log.debug("Serializable types cannot be an interface or abstract, ignoring: {}", mc.getFullyQualifiedName()); return false; } return true; }
private static boolean validateWildcardSerializable(MetaClass mc) { if (mc.isInterface() || (mc.isAbstract() && !mc.isEnum())) { log.debug("Serializable types cannot be an interface or abstract, ignoring: {}", mc.getFullyQualifiedName()); return false; } return true; }
private static boolean validateWildcard(MetaClass bindable) { if (bindable.isInterface()) { log.debug("@Bindable types cannot be an interface, ignoring: {}", bindable.getFullyQualifiedName()); return false; } else if (bindable.isAbstract()) { log.debug("@Bindable types cannot be abstract, ignoring: {}", bindable.getFullyQualifiedName()); return false; } else if (bindable.isFinal()) { log.debug("@Bindable types cannot be final, ignoring: {}", bindable.getFullyQualifiedName()); return false; } return true; } }
private static boolean validateWildcard(MetaClass bindable) { if (bindable.isInterface()) { log.debug("@Bindable types cannot be an interface, ignoring: {}", bindable.getFullyQualifiedName()); return false; } else if (bindable.isAbstract()) { log.debug("@Bindable types cannot be abstract, ignoring: {}", bindable.getFullyQualifiedName()); return false; } else if (bindable.isFinal()) { log.debug("@Bindable types cannot be final, ignoring: {}", bindable.getFullyQualifiedName()); return false; } return true; } }
@Override public boolean shouldUseObjectMarshaller(final MetaClass type) { final boolean hasPortableSubtypes = inheritanceMap.containsKey(type.getFullyQualifiedName()); final MappingDefinition definition = getDefinition(type); final boolean hasMarshaller = definition != null; if (hasMarshaller) { if (definition.getClass().isAnnotationPresent(CustomMapping.class) || definition.getClientMarshallerClass() != null) { return false; } } final boolean isConcrete = !(type.isAbstract() || type.isInterface()); if (!type.isArray() && !type.isEnum() && !isConcrete && !hasPortableSubtypes) { throw new IllegalStateException("A field of type " + type + " appears in a portable class, but " + type + " has no portable implementations."); } return (hasPortableSubtypes && !hasMarshaller) || (hasPortableSubtypes && hasMarshaller && isConcrete); }
@Override public boolean shouldUseObjectMarshaller(final MetaClass type) { final boolean hasPortableSubtypes = inheritanceMap.containsKey(type.getFullyQualifiedName()); final MappingDefinition definition = getDefinition(type); final boolean hasMarshaller = definition != null; if (hasMarshaller) { if (definition.getClass().isAnnotationPresent(CustomMapping.class) || definition.getClientMarshallerClass() != null) { return false; } } final boolean isConcrete = !(type.isAbstract() || type.isInterface()); if (!type.isArray() && !type.isEnum() && !isConcrete && !hasPortableSubtypes) { throw new IllegalStateException("A field of type " + type + " appears in a portable class, but " + type + " has no portable implementations."); } return (hasPortableSubtypes && !hasMarshaller) || (hasPortableSubtypes && hasMarshaller && isConcrete); }
public static int scoreInterface(final MetaClass parm, final MetaClass arg) { if (parm.isInterface()) { final MetaClass[] iface = arg.getInterfaces(); if (iface != null) { for (final MetaClass c : iface) { if (c == parm) return 1; else if (parm.isAssignableFrom(c)) return scoreInterface(parm, arg.getSuperClass()); } } } return 0; }
public static int scoreInterface(final MetaClass parm, final MetaClass arg) { if (parm.isInterface()) { final MetaClass[] iface = arg.getInterfaces(); if (iface != null) { for (final MetaClass c : iface) { if (c == parm) return 1; else if (parm.isAssignableFrom(c)) return scoreInterface(parm, arg.getSuperClass()); } } } return 0; }
private void maybeImplementConstructor(final ClassStructureBuilder<?> proxyImpl, final Injectable injectable) { if (injectable.getInjectedType().isInterface()) { return; } final MetaConstructor accessibleConstructor = getAccessibleConstructor(injectable); if (accessibleConstructor.getParameters().length > 0) { implementConstructor(proxyImpl, accessibleConstructor); } }
public boolean isConcrete() { return !isInterface() && !isAbstract() && !isSynthetic() && !isAnonymousClass() && !isPrimitive() && !isArray() && !isAnnotation() && !isEnum(); }
public boolean isConcrete() { return !isInterface() && !isAbstract() && !isSynthetic() && !isAnonymousClass() && !isPrimitive() && !isArray() && !isAnnotation() && !isEnum(); }
private boolean shouldProxyMethod(final MetaMethod method, final Multimap<String, MetaMethod> proxiedMethodsByName) { return (method.getDeclaringClass() != null && method.getDeclaringClass().isInterface()) || !method.isStatic() && (method.isPublic() || method.isProtected()) && !method.isFinal() && methodIsNotFromObjectUnlessHashCode(method) && typesInSignatureAreVisible(method) && isNotAlreadyProxied(method, proxiedMethodsByName); }
@Override public String generate(final Context context) { final String stmt = statement.generate(context); if (!toType.isPrimitive() && !toType.isAssignableFrom(statement.getType()) && !toType.isAssignableTo(statement.getType()) && !toType.isInterface() && !statement.getType().asBoxed().equals(toType)) { if (context.isPermissiveMode()) { return "(" + LoadClassReference.getClassReference(toType, context) + ") " + stmt; } else { throw new InvalidTypeException(statement.getType() + " cannot be cast to " + toType); } } else if (toType.isAssignableFrom(statement.getType()) && !statement.getType().equals(MetaClassFactory.get(NullType.class))) { return stmt; } else { return "(" + LoadClassReference.getClassReference(toType, context) + ") " + stmt; } }
@Override public String generate(final Context context) { final String stmt = statement.generate(context); if (!toType.isPrimitive() && !toType.isAssignableFrom(statement.getType()) && !toType.isAssignableTo(statement.getType()) && !toType.isInterface() && !statement.getType().asBoxed().equals(toType)) { if (context.isPermissiveMode()) { return "(" + LoadClassReference.getClassReference(toType, context) + ") " + stmt; } else { throw new InvalidTypeException(statement.getType() + " cannot be cast to " + toType); } } else if (toType.isAssignableFrom(statement.getType()) && !statement.getType().equals(MetaClassFactory.get(NullType.class))) { return stmt; } else { return "(" + LoadClassReference.getClassReference(toType, context) + ") " + stmt; } }