use of io.atlasmap.core.ConstantModule in project atlasmap by atlasmap.
the class AtlasField method readConstant.
/**
* Reads the constant.
* @param name name
* @return read field
* @throws AtlasException unexpected error
*/
public AtlasField readConstant(String name) throws AtlasException {
ConstantModule module = session.getConstantModule();
List<Constant> constants = session.getMapping().getConstants().getConstant();
for (Constant constant : constants) {
if (constant.getName() != null && constant.getName().equals(name)) {
Field sourceField = module.createField();
sourceField.setName(constant.getName());
sourceField.setFieldType(constant.getFieldType());
sourceField.setValue(constant.getValue());
session.head().setSourceField(sourceField);
module.readSourceValue(session);
setRawField(sourceField);
return this;
}
}
throw new AtlasException(String.format("Constant '%s' not found", name));
}
Aggregations