@Test public void testPrimitiveValueTemplate() throws Exception { Root root = new Root( null, new Child(null, 1, 2), null ); Optional<Object> sanitizedOpt = new TemplateSanitizer( path -> path.equals("child.childName") ? Optional.of("ChildGuest") : Optional.empty(), type -> true ).apply(root); assertThat(sanitizedOpt).isPresent(); Root sanitized = (Root) sanitizedOpt.get(); assertThat(sanitized.getName()).isNull(); assertThat(sanitized.getChild().getChildName()).isEqualTo("ChildGuest"); assertThat(sanitized.getChild().getMin()).isEqualTo(1); assertThat(sanitized.getChild().getMax()).isEqualTo(2); assertThat(sanitized.getNullableChild()).isNull(); }
@Override public Optional<Object> apply(Object entity) { return entity != null ? apply(entity, "") : Optional.empty(); }
TemplateSanitizer extends AbstractFieldSanitizer<String> { @Override public Optional<Object> apply(Object entity) { return entity != null ? apply(entity, "") : Optional.empty(); } }
TemplateSanitizer extends AbstractFieldSanitizer<String> { @Override public Optional<Object> apply(Object entity) { return entity != null ? apply(entity, "") : Optional.empty(); } TemplateSanitizer(Function<String, Optional<Object>> templateResolver,
                             Function<Class<?>, Boolean> innerEntityPredicate); }
TemplateSanitizer extends AbstractFieldSanitizer<String> { @Override public Optional<Object> apply(Object entity) { return entity != null ? apply(entity, "") : Optional.empty(); } TemplateSanitizer(Function<String, Optional<Object>> templateResolver,
                             Function<Class<?>, Boolean> innerEntityPredicate); @Override Optional<Object> apply(Object entity); }
TemplateSanitizer extends AbstractFieldSanitizer<String> { @Override public Optional<Object> apply(Object entity) { return entity != null ? apply(entity, "") : Optional.empty(); } TemplateSanitizer(Function<String, Optional<Object>> templateResolver,
                             Function<Class<?>, Boolean> innerEntityPredicate); @Override Optional<Object> apply(Object entity);  }