private boolean hasValidationConstraint(BeanSpec spec) { for (Annotation anno : spec.allAnnotations()) { Class<? extends Annotation> annoType = anno.annotationType(); if (Valid.class == annoType || annoType.isAnnotationPresent(Constraint.class)) { return true; } } return false; }
private boolean hasValidationConstraint(BeanSpec spec) { for (Annotation anno : spec.allAnnotations()) { Class<? extends Annotation> annoType = anno.annotationType(); if (Valid.class == annoType || annoType.isAnnotationPresent(Constraint.class)) { return true; } } return false; }
private Map<Class<? extends Annotation>, ActionMethodParamAnnotationHandler> paramAnnoHandlers(BeanSpec spec) { Map<Class<? extends Annotation>, ActionMethodParamAnnotationHandler> handlers = annoHandlers.get(spec); if (null != handlers) { return handlers; } Map<Class<? extends Annotation>, ActionMethodParamAnnotationHandler> newHandlers = new HashMap<>(); for (Annotation annotation : spec.allAnnotations()) { Class<? extends Annotation> c = annotation.annotationType(); ActionMethodParamAnnotationHandler h = allAnnotationHandlers.get(c); if (null != h) { newHandlers.put(c, h); } } handlers = annoHandlers.putIfAbsent(spec, newHandlers); if (null == handlers) { handlers = newHandlers; } return handlers; }
private Map<Class<? extends Annotation>, ActionMethodParamAnnotationHandler> paramAnnoHandlers(BeanSpec spec) { Map<Class<? extends Annotation>, ActionMethodParamAnnotationHandler> handlers = annoHandlers.get(spec); if (null != handlers) { return handlers; } Map<Class<? extends Annotation>, ActionMethodParamAnnotationHandler> newHandlers = new HashMap<>(); for (Annotation annotation : spec.allAnnotations()) { Class<? extends Annotation> c = annotation.annotationType(); ActionMethodParamAnnotationHandler h = allAnnotationHandlers.get(c); if (null != h) { newHandlers.put(c, h); } } handlers = annoHandlers.putIfAbsent(spec, newHandlers); if (null == handlers) { handlers = newHandlers; } return handlers; }
private static String dbBindName(BeanSpec spec) { for (Annotation annotation : spec.allAnnotations()) { if (annotation.annotationType().getName().equals(DbBind.class.getName())) { String value = $.invokeVirtual(annotation, "value"); return (S.blank(value)) ? spec.name() : value; } } return null; }
private static String dbBindName(BeanSpec spec) { for (Annotation annotation : spec.allAnnotations()) { if (annotation.annotationType().getName().equals(DbBind.class.getName())) { String value = $.invokeVirtual(annotation, "value"); return (S.blank(value)) ? spec.name() : value; } } return null; }
public static boolean providedButNotDbBind(BeanSpec beanSpec, DependencyInjector<?> injector) { if (!provided(beanSpec, injector)) { return false; } Annotation[] aa = beanSpec.allAnnotations(); return !hasDbBind(aa); }
public static boolean providedButNotDbBind(BeanSpec beanSpec, DependencyInjector<?> injector) { if (!provided(beanSpec, injector)) { return false; } Annotation[] aa = beanSpec.allAnnotations(); return !hasDbBind(aa); }
public static String bindName(BeanSpec beanSpec) { return bindName(beanSpec.allAnnotations(), beanSpec.name()); }
public static String bindName(BeanSpec beanSpec) { return bindName(beanSpec.allAnnotations(), beanSpec.name()); }
private ParamValueLoader paramValueLoaderOf(BeanSpec spec, String bindName, ActContext ctx) { Class<?> rawType = spec.rawType(); if (Result.class.isAssignableFrom(rawType)) { return RESULT_LOADER; } else if (Throwable.class.isAssignableFrom(rawType)) { return new ThrowableLoader((Class<? extends Throwable>) rawType); } else if (Annotation.class.isAssignableFrom(rawType)) { return findHandlerMethodAnnotation((Class<? extends Annotation>) rawType, ctx); } Type type = spec.type(); Annotation[] annotations = spec.allAnnotations(); $.T2<Type, Annotation[]> key = $.T2(type, annotations); ParamValueLoader loader = paramRegistry.get(key); if (null == loader) { ParamValueLoader newLoader = findLoader(bindName, spec); if (null != newLoader) { // Cannot use spec as the key here because // spec does not compare Scoped annotation loader = paramRegistry.putIfAbsent(key, newLoader); if (null == loader) { loader = newLoader; } } } return loader; }
private ParamValueLoader paramValueLoaderOf(BeanSpec spec, String bindName, ActContext ctx) { Class<?> rawType = spec.rawType(); if (Result.class.isAssignableFrom(rawType)) { return RESULT_LOADER; } else if (Throwable.class.isAssignableFrom(rawType)) { return new ThrowableLoader((Class<? extends Throwable>) rawType); } else if (Annotation.class.isAssignableFrom(rawType)) { return findHandlerMethodAnnotation((Class<? extends Annotation>) rawType, ctx); } Type type = spec.type(); Annotation[] annotations = spec.allAnnotations(); $.T2<Type, Annotation[]> key = $.T2(type, annotations); ParamValueLoader loader = paramRegistry.get(key); if (null == loader) { ParamValueLoader newLoader = findLoader(bindName, spec); if (null != newLoader) { // Cannot use spec as the key here because // spec does not compare Scoped annotation loader = paramRegistry.putIfAbsent(key, newLoader); if (null == loader) { loader = newLoader; } } } return loader; }
for (Annotation tag : beanSpec.allAnnotations()) { Class<? extends Annotation> tagType = tag.annotationType(); if (tagType.isAnnotationPresent(InjectTag.class)) {
for (Annotation tag : beanSpec.allAnnotations()) { Class<? extends Annotation> tagType = tag.annotationType(); if (tagType.isAnnotationPresent(InjectTag.class)) {
private StringValueResolver findIndirectAnnotatedResolver(BeanSpec spec) { Annotation[] aa = spec.allAnnotations(); Class<?> rawType = spec.rawType(); for (Annotation a : aa) { Resolve resolve = AnnotationUtil.tagAnnotation(a, Resolve.class); if (null != resolve) { Class<? extends StringValueResolver>[] resolvers = resolve.value(); for (Class<? extends StringValueResolver> resolverClass : resolvers) { StringValueResolver resolver = injector.get(resolverClass); resolver.attributes($.evaluate(a)); Class<?> targetType = resolver.targetType(); boolean matches = rawType.isAssignableFrom(targetType); if (!matches) { Class<?> rawType2 = $.wrapperClassOf(rawType); if (rawType != rawType2) { matches = rawType2.isAssignableFrom(targetType); } } if (matches) { return resolver; } } } } return null; }
private StringValueResolver findIndirectAnnotatedResolver(BeanSpec spec) { Annotation[] aa = spec.allAnnotations(); Class<?> rawType = spec.rawType(); for (Annotation a : aa) { Resolve resolve = AnnotationUtil.tagAnnotation(a, Resolve.class); if (null != resolve) { Class<? extends StringValueResolver>[] resolvers = resolve.value(); for (Class<? extends StringValueResolver> resolverClass : resolvers) { StringValueResolver resolver = injector.get(resolverClass); resolver.attributes($.evaluate(a)); Class<?> targetType = resolver.targetType(); boolean matches = rawType.isAssignableFrom(targetType); if (!matches) { Class<?> rawType2 = $.wrapperClassOf(rawType); if (rawType != rawType2) { matches = rawType2.isAssignableFrom(targetType); } } if (matches) { return resolver; } } } } return null; }
private ParamValueLoader findLoader( String bindName, BeanSpec spec ) { if (provided(spec, injector)) { return ProvidedValueLoader.get(spec, injector); } if (spec.hasAnnotation(NoBind.class)) { return null; } if (null == bindName) { bindName = bindName(spec.allAnnotations(), spec.name()); } ParamValueLoader loader = findContextSpecificLoader(bindName, spec); if (null == loader) { return null; } return decorate(loader, spec, supportJsonDecorator(), false); }
private ParamValueLoader findLoader( String bindName, BeanSpec spec ) { if (provided(spec, injector)) { return ProvidedValueLoader.get(spec, injector); } if (spec.hasAnnotation(NoBind.class)) { return null; } if (null == bindName) { bindName = bindName(spec.allAnnotations(), spec.name()); } ParamValueLoader loader = findContextSpecificLoader(bindName, spec); if (null == loader) { return null; } return decorate(loader, spec, supportJsonDecorator(), false); }
private ParamInfo paramInfo(Type type, Map<String, Class> typeParamLookup, Annotation[] annos, DependencyInjector injector, String name) { if (isLoginUser(annos)) { return null; } BeanSpec spec = BeanSpec.of(type, annos, name, injector, typeParamLookup); if (ParamValueLoaderService.providedButNotDbBind(spec, injector)) { return null; } if (ParamValueLoaderService.hasDbBind(spec.allAnnotations())) { if (org.osgl.util.S.blank(name)) { name = spec.name(); } return new ParamInfo(name, BeanSpec.of(String.class, injector, typeParamLookup), name + " id"); } String description = ""; Description descAnno = spec.getAnnotation(Description.class); if (null != descAnno) { description = descAnno.value(); } return new ParamInfo(spec.name(), spec, description); }
private ParamInfo paramInfo(Type type, Map<String, Class> typeParamLookup, Annotation[] annos, DependencyInjector injector, String name) { if (isLoginUser(annos)) { return null; } BeanSpec spec = BeanSpec.of(type, annos, name, injector, typeParamLookup); if (ParamValueLoaderService.providedButNotDbBind(spec, injector)) { return null; } if (ParamValueLoaderService.hasDbBind(spec.allAnnotations())) { if (org.osgl.util.S.blank(name)) { name = spec.name(); } return new ParamInfo(name, BeanSpec.of(String.class, injector, typeParamLookup), name + " id"); } String description = ""; Description descAnno = spec.getAnnotation(Description.class); if (null != descAnno) { description = descAnno.value(); } return new ParamInfo(spec.name(), spec, description); }