@Override public void resolve(AutoConfigContext context, PropertyDescriptor descriptor, Class<?> propertyType) { final Collection collection = createCollection(propertyType); final Class<?> itemType = GenericsUtils.getMethodGenericReturnType(descriptor.getReadMethod(), 0); doFilter(context, descriptor, new Filter() { @Override public boolean onCondition(String name, String key, String value) { return key.startsWith(name); } @Override public boolean call(String name, String key, String value) { if (itemType == Class.class) { try { collection.add(Class.forName(value)); } catch (ClassNotFoundException e) { throw new PropertiesConfigurationResolveException(e); } } else if (PrimitiveTypeUtils.isPrimitiveClass(itemType)) { collection.add(PrimitiveTypeUtils.convert(value, itemType)); } else { collection.add(JSON.parse(value, itemType)); } return true; } }); writeProperty(context, descriptor, collection); }
@Override public void resolve(AutoConfigContext context, PropertyDescriptor descriptor, Class<?> propertyType) { final Collection collection = createCollection(propertyType); final Class<?> itemType = GenericsUtils.getMethodGenericReturnType(descriptor.getReadMethod(), 0); doFilter(context, descriptor, new Filter() { @Override public boolean onCondition(String name, String key, String value) { return key.startsWith(name); } @Override public boolean call(String name, String key, String value) { if (itemType == Class.class) { try { collection.add(Class.forName(value)); } catch (ClassNotFoundException e) { throw new PropertiesConfigurationResolveException(e); } } else if (PrimitiveTypeUtils.isPrimitiveClass(itemType)) { collection.add(PrimitiveTypeUtils.convert(value, itemType)); } else { collection.add(JSON.parse(value, itemType)); } return true; } }); writeProperty(context, descriptor, collection); }
@Override public void resolve(AutoConfigContext context, PropertyDescriptor descriptor, Class<?> propertyType) { final Collection collection = createCollection(propertyType); final Class<?> itemType = GenericsUtils.getMethodGenericReturnType(descriptor.getReadMethod(), 0); doFilter(context, descriptor, new Filter() { @Override public boolean onCondition(String name, String key, String value) { return key.startsWith(name); } @Override public boolean call(String name, String key, String value) { if (itemType == Class.class) { try { collection.add(Class.forName(value)); } catch (ClassNotFoundException e) { throw new PropertiesConfigurationResolveException(e); } } else if (PrimitiveTypeUtils.isPrimitiveClass(itemType)) { collection.add(PrimitiveTypeUtils.convert(value, itemType)); } else { collection.add(JSON.parse(value, itemType)); } return true; } }); writeProperty(context, descriptor, collection); }