DBZ-576 Internal parameters

This commit is contained in:
Jiri Pechanec 2018-01-25 10:00:33 +01:00 committed by Gunnar Morling
parent a77c8d733a
commit 3740aee4e8
2 changed files with 20 additions and 0 deletions

View File

@ -46,6 +46,9 @@
*/
@Immutable
public final class Field {
public static final String INTERNAL_PREFIX = "internal.";
/**
* Create a set of fields.
*
@ -237,6 +240,17 @@ public static Field create(String name) {
return new Field(name, null, null, null, null, null, null, null);
}
/**
* Create an immutable internal {@link Field} instance with the given property name.
* The name will be prefixed with {@code internal.} prefix.
*
* @param name the name of the field; may not be null
* @return the field; never null
*/
public static Field createInternal(String name) {
return new Field(INTERNAL_PREFIX + name, null, null, null, null, null, null, null, null, null);
}
/**
* Create an immutable {@link Field} instance with the given property name.
*

View File

@ -49,6 +49,12 @@ public void shouldConvertFromProperties() {
assertThat(config.getBoolean("1")).isNull(); // not a boolean
}
@Test
public void shoulCreateInternalFields() {
config = Configuration.create().with(Field.createInternal("a"), "a1").build();
assertThat(config.getString("internal.a")).isEqualTo("a1");
}
@Test
public void shouldCallFunctionOnEachMatchingFieldUsingRegex() {
config = Configuration.create()