/** * Return a {@link RelaxedNames} for the given source camelCase source name. * @param name the source name in camelCase * @return the relaxed names */ public static RelaxedNames forCamelCase(String name) { return new RelaxedNames(Manipulation.CAMELCASE_TO_HYPHEN.apply(name)); }
public AutoConfigContext build() { buildPropertyDescriptors(); buildNameDescriptorMap(prefix, propertyDescriptors); return new AutoConfigContext(nameDescriptorMap, descriptorNameMap, propMap, targetObj); }
/** * Create a new {@link RelaxedNames} instance. * @param name the source name. For the maximum number of variations specify the name * using dashed notation (e.g. {@literal my-property-name} */ public RelaxedNames(String name) { this.name = (name == null ? "" : name); initialize(RelaxedNames.this.name, this.values); }
@Override protected TaskTracker build0() { TaskTrackerProperties properties = PropertiesConfigurationFactory.createPropertiesConfiguration(TaskTrackerProperties.class, locations); return buildByProperties(properties); }
private void initialize(String name, Set<String> values) { if (values.contains(name)) { return; } for (Variation variation : Variation.values()) { for (Manipulation manipulation : Manipulation.values()) { String result = name; result = manipulation.apply(result); result = variation.apply(result); values.add(result); initialize(result, values); } } }
protected void writeProperty(AutoConfigContext context, PropertyDescriptor descriptor, Object value) { try { Method writeMethod = descriptor.getWriteMethod(); writeMethod.invoke(context.getTargetObject(), value); } catch (Exception e) { throw new PropertiesConfigurationResolveException("Inject Property " + descriptor.getName() + " Error", e); } }
@Override public boolean call(String name, String key, String value) { try { Class clazz = Class.forName(value); writeProperty(context, descriptor, clazz); } catch (ClassNotFoundException e) { throw new PropertiesConfigurationResolveException(e); } return false; } });
private Class<?> getRawClass(Type type) { if (type instanceof Class<?>) { return (Class<?>) type; } else if (type instanceof ParameterizedType) { return getRawClass(((ParameterizedType) type).getRawType()); } else { throw new PropertiesConfigurationResolveException("can't resolve the rawClass by " + type); } } }
@Override protected JobTracker build0() { JobTrackerProperties properties = PropertiesConfigurationFactory.createPropertiesConfiguration(JobTrackerProperties.class, locations); return buildByProperties(properties); }
private void initialize(String name, Set<String> values) { if (values.contains(name)) { return; } for (Variation variation : Variation.values()) { for (Manipulation manipulation : Manipulation.values()) { String result = name; result = manipulation.apply(result); result = variation.apply(result); values.add(result); initialize(result, values); } } }
public AutoConfigContext build() { buildPropertyDescriptors(); buildNameDescriptorMap(prefix, propertyDescriptors); return new AutoConfigContext(nameDescriptorMap, descriptorNameMap, propMap, targetObj); }
/** * Return a {@link RelaxedNames} for the given source camelCase source name. * @param name the source name in camelCase * @return the relaxed names */ public static RelaxedNames forCamelCase(String name) { return new RelaxedNames(Manipulation.CAMELCASE_TO_HYPHEN.apply(name)); }
protected void writeProperty(AutoConfigContext context, PropertyDescriptor descriptor, Object value) { try { Method writeMethod = descriptor.getWriteMethod(); writeMethod.invoke(context.getTargetObject(), value); } catch (Exception e) { throw new PropertiesConfigurationResolveException("Inject Property " + descriptor.getName() + " Error", e); } }
@Override public boolean call(String name, String key, String value) { try { Class clazz = Class.forName(value); writeProperty(context, descriptor, clazz); } catch (ClassNotFoundException e) { throw new PropertiesConfigurationResolveException(e); } return false; } });
private Class<?> getRawClass(Type type) { if (type instanceof Class<?>) { return (Class<?>) type; } else if (type instanceof ParameterizedType) { return getRawClass(((ParameterizedType) type).getRawType()); } else { throw new PropertiesConfigurationResolveException("can't resolve the rawClass by " + type); } } }
/** * Create a new {@link RelaxedNames} instance. * @param name the source name. For the maximum number of variations specify the name * using dashed notation (e.g. {@literal my-property-name} */ public RelaxedNames(String name) { this.name = (name == null ? "" : name); initialize(RelaxedNames.this.name, this.values); }
@Override protected TaskTracker build0() { TaskTrackerProperties properties = PropertiesConfigurationFactory.createPropertiesConfiguration(TaskTrackerProperties.class, locations); return buildByProperties(properties); }
@Override protected JobTracker build0() { JobTrackerProperties properties = PropertiesConfigurationFactory.createPropertiesConfiguration(JobTrackerProperties.class, locations); return buildByProperties(properties); }
@Override protected JobClient build0() { JobClientProperties properties = PropertiesConfigurationFactory .createPropertiesConfiguration(JobClientProperties.class, locations); JobClient jobClient = buildByProperties(properties); if (jobCompletedHandler != null) { jobClient.setJobCompletedHandler(jobCompletedHandler); } return jobClient; }
@Override protected JobClient build0() { JobClientProperties properties = PropertiesConfigurationFactory .createPropertiesConfiguration(JobClientProperties.class, locations); JobClient jobClient = buildByProperties(properties); if (jobCompletedHandler != null) { jobClient.setJobCompletedHandler(jobCompletedHandler); } return jobClient; }