use of org.apache.hop.pipeline.transforms.loadsave.setter.ISetter in project hop by apache.
the class LoadSaveBase method createValidatorMapAndInvokeSetters.
@SuppressWarnings({ "unchecked" })
protected Map<String, IFieldLoadSaveValidator<?>> createValidatorMapAndInvokeSetters(List<String> attributes, T metaToSave) {
Map<String, IFieldLoadSaveValidator<?>> validatorMap = new HashMap<>();
metadataProvider = new MemoryMetadataProvider();
for (String attribute : attributes) {
IGetter<?> getter = manipulator.getGetter(attribute);
@SuppressWarnings("rawtypes") ISetter setter = manipulator.getSetter(attribute);
IFieldLoadSaveValidator<?> validator = fieldLoadSaveValidatorFactory.createValidator(getter);
try {
Object testValue = validator.getTestObject();
// no-inspection unchecked
setter.set(metaToSave, testValue);
if (testValue instanceof DatabaseMeta) {
addDatabase((DatabaseMeta) testValue);
} else if (testValue instanceof DatabaseMeta[]) {
addDatabase((DatabaseMeta[]) testValue);
}
} catch (Exception e) {
throw new RuntimeException("Unable to invoke setter for " + attribute, e);
}
validatorMap.put(attribute, validator);
}
return validatorMap;
}
use of org.apache.hop.pipeline.transforms.loadsave.setter.ISetter in project hop by apache.
the class ObjectValidator method getTestObject.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public T getTestObject() {
try {
T object = clazz.newInstance();
for (String attribute : fieldNames) {
ISetter setter = manipulator.getSetter(attribute);
setter.set(object, fieldLoadSaveValidatorFactory.createValidator(manipulator.getGetter(attribute)).getTestObject());
}
return object;
} catch (Exception e) {
throw new RuntimeException("Unable to instantiate " + clazz, e);
}
}
use of org.apache.hop.pipeline.transforms.loadsave.setter.ISetter in project hop by apache.
the class LoadSaveTester method createValidatorMapAndInvokeSetters.
@Override
@SuppressWarnings("unchecked")
protected Map<String, IFieldLoadSaveValidator<?>> createValidatorMapAndInvokeSetters(List<String> attributes, T metaToSave) {
Map<String, IFieldLoadSaveValidator<?>> validatorMap = new HashMap<>();
for (String attribute : attributes) {
IGetter<?> getter = manipulator.getGetter(attribute);
@SuppressWarnings("rawtypes") ISetter setter = manipulator.getSetter(attribute);
IFieldLoadSaveValidator<?> validator = fieldLoadSaveValidatorFactory.createValidator(getter);
try {
Object testValue = validator.getTestObject();
setter.set(metaToSave, testValue);
if (validator instanceof DatabaseMetaLoadSaveValidator) {
addDatabase((DatabaseMeta) testValue);
}
} catch (Exception e) {
throw new RuntimeException("Unable to invoke setter for " + attribute, e);
}
validatorMap.put(attribute, validator);
}
return validatorMap;
}
Aggregations