use of io.atlasmap.v2.Length in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionService method detectFieldActionParameters.
protected Properties detectFieldActionParameters(String actionClassName) throws ClassNotFoundException {
Class<?> actionClazz = Class.forName(actionClassName);
Properties props = null;
for (Method method : actionClazz.getMethods()) {
// Find setters to avoid the get / is confusion
if (method.getParameterCount() == 1 && method.getName().startsWith("set")) {
// We have a parameter
if (props == null) {
props = new Properties();
}
Property prop = null;
for (Parameter param : method.getParameters()) {
prop = new Property();
prop.setName(camelize(method.getName().substring("set".length())));
prop.setFieldType(getConversionService().fieldTypeFromClass(param.getType()));
props.getProperty().add(prop);
}
}
}
return props;
}
use of io.atlasmap.v2.Length in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateActions.
private Actions generateActions() {
Actions actions = new Actions();
actions.getActions().add(new Camelize());
actions.getActions().add(new Capitalize());
actions.getActions().add(new Length());
actions.getActions().add(new Lowercase());
actions.getActions().add(new SeparateByDash());
actions.getActions().add(new SeparateByUnderscore());
actions.getActions().add(new Trim());
actions.getActions().add(new TrimLeft());
actions.getActions().add(new TrimRight());
actions.getActions().add(new Uppercase());
return actions;
}
use of io.atlasmap.v2.Length in project atlasmap by atlasmap.
the class StringLengthValidatorTest method testValidateInvalid.
@Test
public void testValidateInvalid() {
String pass = "";
validator.validate(pass, validations, "testValidateInvalid");
assertTrue(validationHelper.hasErrors());
assertEquals(new Integer(1), new Integer(validationHelper.getAllValidations().size()));
Validation validation = validations.get(0);
assertNotNull(validation);
assertEquals(ValidationScope.MAPPING, validation.getScope());
assertEquals("testValidateInvalid", validation.getId());
assertTrue("Must be of this length".equals(validation.getMessage()));
}
use of io.atlasmap.v2.Length in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateActions.
private Actions generateActions() {
Actions actions = new Actions();
actions.getActions().add(new Camelize());
actions.getActions().add(new Capitalize());
actions.getActions().add(new Length());
actions.getActions().add(new Lowercase());
actions.getActions().add(new SeparateByDash());
actions.getActions().add(new SeparateByUnderscore());
actions.getActions().add(new Trim());
actions.getActions().add(new TrimLeft());
actions.getActions().add(new TrimRight());
actions.getActions().add(new Uppercase());
return actions;
}
use of io.atlasmap.v2.Length in project atlasmap by atlasmap.
the class StringComplexFieldActions method subStringAfter.
@AtlasFieldActionInfo(name = "SubStringAfter", sourceType = FieldType.STRING, targetType = FieldType.STRING, sourceCollectionType = CollectionType.NONE, targetCollectionType = CollectionType.NONE)
public static String subStringAfter(Action action, String input) {
if (input == null || input.length() == 0) {
return input;
}
if (action == null || !(action instanceof SubStringAfter) || ((SubStringAfter) action).getStartIndex() == null || ((SubStringAfter) action).getStartIndex() < 0 || ((SubStringAfter) action).getMatch() == null || (((SubStringAfter) action).getEndIndex() != null && ((SubStringAfter) action).getEndIndex() < ((SubStringAfter) action).getStartIndex())) {
throw new IllegalArgumentException("SubStringAfter action must be specified with a positive startIndex and a string to match");
}
SubStringAfter subStringAfter = (SubStringAfter) action;
int idx = input.indexOf(subStringAfter.getMatch());
if (idx < 0) {
return input;
}
idx = idx + subStringAfter.getMatch().length();
return doSubString(input.substring(idx), subStringAfter.getStartIndex(), subStringAfter.getEndIndex());
}
Aggregations