private void exploreDateTimeType() { List<Type> types = Generics.typeParamImplementations(getClass(), StringValueResolver.class); dateTimeType = (Class<?>) types.get(0); }
/** * Build class type variable name and type variable implementation lookup * * @param theClass the class to build the lookup * @return the lookup */ public static Map<String, Class> buildTypeParamImplLookup(Class theClass) { Map<String, Class> lookup = new HashMap<>(); buildTypeParamImplLookup(theClass, lookup); return lookup; }
private void exploreTypes() { List<Type> types = Generics.typeParamImplementations(getClass(), ClassMetaInfoManager.class); infoType = Generics.classOf(types.get(0)); } }
private void exploreTypes() { Map<String, Class> typeParamLookup = Generics.buildTypeParamImplLookup(getClass()); List<Type> types = Generics.typeParamImplementations(getClass(), SimpleRestfulServiceBase.class); int sz = types.size(); if (sz < 3) { throw new IllegalArgumentException("Cannot determine DAO type"); } Type daoType = types.get(2); BeanSpec spec = BeanSpec.of(daoType, Act.injector(), typeParamLookup); DaoLoader loader = Act.getInstance(DaoLoader.class); dao = $.cast(loader.load(spec)); }
if (typeParam instanceof Class) { TypeVariable typeVar = typeArgs[i]; lookup.put(lookupKey(typeVar, prefix), (Class) typeParam); } else if (typeParam instanceof TypeVariable) { TypeVariable var = $.cast(typeParam); TypeVariable typeVar = typeArgs[i]; if (null != impl) { lookup.put(lookupKey(typeVar, prefix), impl); } else { Type[] ta = var.getBounds(); Type bound = ta[0]; if (bound instanceof Class) { lookup.put(lookupKey(typeVar, prefix), (Class) bound); Map<String, Class> subLookup = subLookup(lookup, name); if (!subLookup.isEmpty()) { String newPrefix = typeVar.getName() + "."; Type rawType = ptype0.getRawType(); if (rawType instanceof Class) { lookup.put(lookupKey(typeVar, prefix), (Class) rawType); buildTypeParamImplLookup(lookupKey(typeVar, prefix), ptype0.getActualTypeArguments(), ((Class) rawType).getTypeParameters(), lookup); } else { throw new UnexpectedException("Unknown typeParam: " + ptype0);
protected Class<ID_TYPE> idType() { return Generics.classOf(idType); }
Class<?> controllerClass = invoker.controllerClass(); Method method = invoker.method(); returnType = Generics.getReturnType(method, controllerClass); PropertySpec pspec = method.getAnnotation(PropertySpec.class); if (null != pspec) { typeParamLookup = Generics.buildTypeParamImplLookup(controllerClass);
private static boolean shouldWaive(Method getter, Class<?> implementClass) { int modifiers = getter.getModifiers(); if (Modifier.isTransient(modifiers) || Modifier.isStatic(modifiers)) { return true; } String fieldName = getter.getName().substring(3); Class<?> entityType = Generics.getReturnType(getter, implementClass); return ParamValueLoaderService.noBind(entityType) || getter.isAnnotationPresent(NoBind.class) || getter.isAnnotationPresent(Stateless.class) || getter.isAnnotationPresent(Global.class) || ParamValueLoaderService.isInBlackList(fieldName) || Object.class.equals(entityType) || Class.class.equals(entityType) || OsglConfig.globalMappingFilter_shouldIgnore(fieldName); }
private BeanSpec(Type type, Annotation[] annotations, String name, Injector injector, int modifiers, Map<String, Class> typeParamImplLookup) { this.injector = injector; this.type = type; this.originalName = name; this.name = name; this.rawType = rawTypeOf(type, typeParamImplLookup); this.typeParams(typeParamImplLookup); if (null != typeParamImplLookup && type instanceof TypeVariable && rawType.getTypeParameters().length > 0 && !typeParamImplLookup.isEmpty()) { this.fieldTypeImplLookup = Generics.subLookup(typeParamImplLookup, ((TypeVariable) type).getName()); } this.isArray = rawType.isArray(); this.resolveTypeAnnotations(injector); this.resolveAnnotations(annotations, injector, typeParamImplLookup); this.hc = calcHashCode(); this.modifiers = modifiers; }
private void exploreTypes() { Map<String, Class> typeParamLookup = Generics.buildTypeParamImplLookup(getClass()); List<Type> types = Generics.typeParamImplementations(getClass(), SimpleRestfulServiceBase.class); int sz = types.size(); if (sz < 3) { throw new IllegalArgumentException("Cannot determine DAO type"); } Type daoType = types.get(2); BeanSpec spec = BeanSpec.of(daoType, Act.injector(), typeParamLookup); DaoLoader loader = Act.getInstance(DaoLoader.class); dao = $.cast(loader.load(spec)); }
if (typeParam instanceof Class) { TypeVariable typeVar = typeArgs[i]; lookup.put(lookupKey(typeVar, prefix), (Class) typeParam); } else if (typeParam instanceof TypeVariable) { TypeVariable var = $.cast(typeParam); TypeVariable typeVar = typeArgs[i]; if (null != impl) { lookup.put(lookupKey(typeVar, prefix), impl); } else { Type[] ta = var.getBounds(); Type bound = ta[0]; if (bound instanceof Class) { lookup.put(lookupKey(typeVar, prefix), (Class) bound); Map<String, Class> subLookup = subLookup(lookup, name); if (!subLookup.isEmpty()) { String newPrefix = typeVar.getName() + "."; Type rawType = ptype0.getRawType(); if (rawType instanceof Class) { lookup.put(lookupKey(typeVar, prefix), (Class) rawType); buildTypeParamImplLookup(lookupKey(typeVar, prefix), ptype0.getActualTypeArguments(), ((Class) rawType).getTypeParameters(), lookup); } else { throw new UnexpectedException("Unknown typeParam: " + ptype0);
public Class<T> targetType() { return Generics.classOf(targetType); }
Class<?> controllerClass = invoker.controllerClass(); Method method = invoker.method(); returnType = Generics.getReturnType(method, controllerClass); PropertySpec pspec = method.getAnnotation(PropertySpec.class); if (null != pspec) { typeParamLookup = Generics.buildTypeParamImplLookup(controllerClass);
private static boolean shouldWaive(Method getter, Class<?> implementClass) { int modifiers = getter.getModifiers(); if (Modifier.isTransient(modifiers) || Modifier.isStatic(modifiers)) { return true; } String fieldName = getter.getName().substring(3); Class<?> entityType = Generics.getReturnType(getter, implementClass); return ParamValueLoaderService.noBind(entityType) || getter.isAnnotationPresent(NoBind.class) || getter.isAnnotationPresent(Stateless.class) || getter.isAnnotationPresent(Global.class) || ParamValueLoaderService.isInBlackList(fieldName) || Object.class.equals(entityType) || Class.class.equals(entityType) || OsglConfig.globalMappingFilter_shouldIgnore(fieldName); }
private BeanSpec(Type type, Annotation[] annotations, String name, Injector injector, int modifiers, Map<String, Class> typeParamImplLookup) { this.injector = injector; this.type = type; this.originalName = name; this.name = name; this.rawType = rawTypeOf(type, typeParamImplLookup); this.typeParams(typeParamImplLookup); if (null != typeParamImplLookup && type instanceof TypeVariable && rawType.getTypeParameters().length > 0 && !typeParamImplLookup.isEmpty()) { this.fieldTypeImplLookup = Generics.subLookup(typeParamImplLookup, ((TypeVariable) type).getName()); } this.isArray = rawType.isArray(); this.resolveTypeAnnotations(injector); this.resolveAnnotations(annotations, injector, typeParamImplLookup); this.hc = calcHashCode(); this.modifiers = modifiers; }
private void exploreDateTimeType() { List<Type> types = Generics.typeParamImplementations(getClass(), StringValueResolver.class); dateTimeType = (Class<?>) types.get(0); }
private void exploreTypes() { List<Type> types = Generics.typeParamImplementations(getClass(), ClassMetaInfoManager.class); infoType = Generics.classOf(types.get(0)); } }
/** * Build class type variable name and type variable implementation lookup * * @param theClass the class to build the lookup * @return the lookup */ public static Map<String, Class> buildTypeParamImplLookup(Class theClass) { Map<String, Class> lookup = new HashMap<>(); buildTypeParamImplLookup(theClass, lookup); return lookup; }
protected Class<MODEL_TYPE> modelType() { return Generics.classOf(modelType); }
private void buildPropertyPath(String context, Method m, Class<?> c, List<String> repo) { if (m.getParameterTypes().length > 0) { return; } String name = m.getName(); if ("getClass".equals(name)) { return; } String propName = ""; if (name.startsWith("get")) { propName = getPropName(name); } else if (name.startsWith("is")) { propName = isPropName(name); } if (S.isEmpty(propName)) { return; } Class returnType = Generics.getReturnType(m, c); buildPropertyPath(returnType, m.getGenericReturnType(), context, propName, repo); }