private boolean isNativeJSType(final MetaClass type) { final JsType anno = type.getAnnotation(JsType.class); return type.getAnnotation(JsType.class) != null && anno.isNative(); }
private Set<Property> getProperties(final MetaClass type) { final Set<Property> properties = new HashSet<>(); final Property declaredProperty = type.getAnnotation(Property.class); final Properties declaredProperties = type.getAnnotation(Properties.class); if (declaredProperty != null) { properties.add(declaredProperty); } if (declaredProperties != null) { properties.addAll(Arrays.asList(declaredProperties.value())); } return properties; }
private Set<Property> getProperties(final MetaClass type) { final Set<Property> properties = new HashSet<>(); final Property declaredProperty = type.getAnnotation(Property.class); final Properties declaredProperties = type.getAnnotation(Properties.class); if (declaredProperty != null) { properties.add(declaredProperty); } if (declaredProperties != null) { properties.addAll(Arrays.asList(declaredProperties.value())); } return properties; }
private static List<String> gwtElementTags(MetaClass type) { return Optional.ofNullable(type.getAnnotation(TagName.class)) .map(a -> Arrays.asList(a.value())) .orElse(emptyList()); }
private String getPageURL(MetaClass pageClass, String pageName) { Page pageAnnotation = pageClass.getAnnotation(Page.class); String path = pageAnnotation.path(); if (path.equals("")) { return pageName; } return path; }
private String getPageURL(MetaClass pageClass, String pageName) { Page pageAnnotation = pageClass.getAnnotation(Page.class); String path = pageAnnotation.path(); if (path.equals("")) { return pageName; } return path; }
private static List<String> gwtElementTags(MetaClass type) { return Optional.ofNullable(type.getAnnotation(TagName.class)) .map(a -> Arrays.asList(a.value())) .orElse(emptyList()); }
public JaxrsProxyGenerator(MetaClass remote, final GeneratorContext context, final InterceptorProvider interceptorProvider, Multimap<MetaClass, MetaClass> exceptionMappers) { this.remote = remote; this.context = context; this.exceptionMappers = exceptionMappers; this.rootResourcePath = remote.getAnnotation(Path.class).value(); this.headers = JaxrsHeaders.fromClass(remote); this.interceptorProvider = interceptorProvider; }
private static Collection<String> customElementTags(final MetaClass type) { final Element elementAnnotation = type.getAnnotation(Element.class); if (elementAnnotation == null) { return Collections.emptyList(); } final JsType jsTypeAnnotation = type.getAnnotation(JsType.class); if (jsTypeAnnotation == null || !jsTypeAnnotation.isNative()) { final String element = Element.class.getSimpleName(); final String jsType = JsType.class.getSimpleName(); throw new RuntimeException(element + " is only valid on native " + jsType + "s."); } return Arrays.asList(elementAnnotation.value()); }
private List<String> getClassNames(final MetaClass type) { return Optional.ofNullable(type.getAnnotation(ClassNames.class)) .map(a -> Arrays.asList(a.value())) .orElse(emptyList()); } }
private boolean isNativeJsType(final MetaClass eventType) { return Optional .ofNullable(eventType.getAnnotation(JsType.class)).filter(anno -> anno.isNative()).isPresent(); }
private static boolean hasNativeJsTypeAnnotation(final MetaClass type) { final JsType anno = type.getAnnotation(JsType.class); return anno != null && anno.isNative(); }
private String getBeanName(final Injectable injectable) { final Named named = injectable.getInjectedType().getAnnotation(Named.class); return (named != null) ? named.value() : null; }
private List<String> getClassNames(final MetaClass type) { return Optional.ofNullable(type.getAnnotation(ClassNames.class)) .map(a -> Arrays.asList(a.value())) .orElse(emptyList()); } }
private String getPathRoot(final MetaClass bundleClass, final URL resource) { final String fullPath = resource.getPath(); final String resourcePath = bundleClass.getAnnotation(Bundle.class).value(); final String protocol = resource.getProtocol(); final String relativePath; if (resourcePath.startsWith("/")) relativePath = resourcePath; else // Do NOT use File.separatorChar here: Url.getPath() always uses forward-slashes relativePath = bundleClass.getPackageName().replace('.', '/'); final String pathRoot = fullPath.substring(0, fullPath.indexOf(relativePath)); return protocol + ":" + pathRoot; }
private void setFeatureInterceptors(final Collection<MetaClass> featureInterceptors) { for (final MetaClass featureInterceptor : featureInterceptors) { final Class<? extends Annotation>[] annotations = featureInterceptor.getAnnotation(FeatureInterceptor.class).value(); for (int i = 0; i < annotations.length; i++) { this.featureInterceptors.put(annotations[i], featureInterceptor.asClass()); } } }
private void setStandaloneInterceptors(final Collection<MetaClass> standaloneInterceptors) { for (final MetaClass interceptorClass : standaloneInterceptors) { final InterceptsRemoteCall interceptor = interceptorClass.getAnnotation(InterceptsRemoteCall.class); final Class<?>[] intercepts = interceptor.value(); for (final Class<?> intercept : intercepts) { this.standaloneInterceptors.put(intercept, interceptorClass.asClass()); } } }
private Stream<MetaClass> findJsTypeIfaces(final MetaClass type) { return stream(type.getInterfaces()) .flatMap(iface -> stream(iface.getInterfaces())) .distinct() .filter(iface -> !iface.getFullyQualifiedName().startsWith("java.util")) .filter(iface -> iface.isAnnotationPresent(JsType.class) && !iface.getAnnotation(JsType.class).isNative()); }
private Class<?> getAsyncFragmentId(final Injectable injectable) { final LoadAsync loadAsync = injectable.getInjectedType().getAnnotation(LoadAsync.class); if (loadAsync == null) { return LoadAsync.NO_FRAGMENT.class; } else { return loadAsync.value(); } }
private boolean isEnabledByProperty(final MetaClass type) { final EnabledByProperty anno = type.getAnnotation(EnabledByProperty.class); final boolean propValue = getPropertyValue(anno.value(), anno.matchValue(), anno.matchByDefault(), anno.caseSensitive()); final boolean negated = anno.negated(); return propValue ^ negated; }