@Override public String toString() { final StringBuilder sb = new StringBuilder(); final Annotation[] annos = getAnnotations(); if (annos != null) { for (final Annotation anno : annos) { sb.append(anno.toString()).append(" "); } } sb.append(" ").append(GenUtil.scopeOf(this).getCanonicalName()).append(" ") .append(getReturnType()).append(" ") .append(getName()).append("(").append(Arrays.toString(getParameters())).append(")"); return sb.toString(); } }
@Override public String toString() { final StringBuilder sb = new StringBuilder(); final Annotation[] annos = getAnnotations(); if (annos != null) { for (final Annotation anno : annos) { sb.append(anno.toString()).append(" "); } } sb.append(" ").append(GenUtil.scopeOf(this).getCanonicalName()).append(" ") .append(getReturnType()).append(" ") .append(getName()).append("(").append(Arrays.toString(getParameters())).append(")"); return sb.toString(); } }
@Override public List<MetaMethod> getMethodsWithMetaAnnotations(final Class<? extends Annotation> annotation) { final List<MetaMethod> methods = new ArrayList<>(); MetaClass scanTarget = this; while (scanTarget != null) { for (final MetaMethod m : scanTarget.getDeclaredMethods()) { for (final Annotation a : m.getAnnotations()) { if (_findMetaAnnotation(a.annotationType(), annotation)) { methods.add(m); } } } scanTarget = scanTarget.getSuperClass(); } return methods; }
@Override public List<MetaMethod> getMethodsWithMetaAnnotations(final Class<? extends Annotation> annotation) { final List<MetaMethod> methods = new ArrayList<>(); MetaClass scanTarget = this; while (scanTarget != null) { for (final MetaMethod m : scanTarget.getDeclaredMethods()) { for (final Annotation a : m.getAnnotations()) { if (_findMetaAnnotation(a.annotationType(), annotation)) { methods.add(m); } } } scanTarget = scanTarget.getSuperClass(); } return methods; }
/** * If a type uses @JsOverlay or @JsProperty on overrides of HasValue methods, then we must generate * an invocation so the GWT compiler uses the correct JS invocation at runtime. */ private static boolean implementsNativeHasValueAndRequiresGeneratedInvocation(final MetaClass type) { if (type.isAssignableTo(HasValue.class)) { final MetaClass hasValue = MetaClassFactory.get(HasValue.class); final MetaMethod getValue = type.getMethod("getValue", new MetaClass[0]); final MetaMethod setValue = type.getMethod("setValue", getValue.getReturnType()); if (type.isInterface() && (getValue.getDeclaringClass().getErased().equals(hasValue) || setValue.getDeclaringClass().getErased().equals(hasValue))) { /* * In this case, the methods could be default implementations on an interface (not returned by TypeOracle) so we * will assume we need to generate an invocation. */ return true; } else { final Stream<Annotation> getAnnos = Arrays.stream(getValue.getAnnotations()); final Stream<Annotation> setAnnos = Arrays.stream(setValue.getAnnotations()); final Predicate<Annotation> testForOverlayOrProperty = anno -> anno.annotationType() .getPackage() .getName() .equals("jsinterop.annotations"); return getAnnos.anyMatch(testForOverlayOrProperty) || setAnnos.anyMatch(testForOverlayOrProperty); } } return false; }
/** * If a type uses @JsOverlay or @JsProperty on overrides of HasValue methods, then we must generate * an invocation so the GWT compiler uses the correct JS invocation at runtime. */ private static boolean implementsNativeHasValueAndRequiresGeneratedInvocation(final MetaClass type) { if (type.isAssignableTo(HasValue.class)) { final MetaClass hasValue = MetaClassFactory.get(HasValue.class); final MetaMethod getValue = type.getMethod("getValue", new MetaClass[0]); final MetaMethod setValue = type.getMethod("setValue", getValue.getReturnType()); if (type.isInterface() && (getValue.getDeclaringClass().getErased().equals(hasValue) || setValue.getDeclaringClass().getErased().equals(hasValue))) { /* * In this case, the methods could be default implementations on an interface (not returned by TypeOracle) so we * will assume we need to generate an invocation. */ return true; } else { final Stream<Annotation> getAnnos = Arrays.stream(getValue.getAnnotations()); final Stream<Annotation> setAnnos = Arrays.stream(setValue.getAnnotations()); final Predicate<Annotation> testForOverlayOrProperty = anno -> anno.annotationType() .getPackage() .getName() .equals("jsinterop.annotations"); return getAnnos.anyMatch(testForOverlayOrProperty) || setAnnos.anyMatch(testForOverlayOrProperty); } } return false; }
.finish() .publicOverridesMethod("getAnnotations") .append(Stmt.load(filter(method.getAnnotations(), translatablePackages)).returnValue()) .finish() .publicOverridesMethod("getTypeAnnotations")
.finish() .publicOverridesMethod("getAnnotations") .append(Stmt.load(filter(method.getAnnotations(), translatablePackages)).returnValue()) .finish() .publicOverridesMethod("getTypeAnnotations")