@Test public void should_support_property_sets() { PropertyDefinition def = PropertyDefinition.builder("hello") .name("Hello") .fields( PropertyFieldDefinition.build("first").name("First").description("Description").options("A", "B").build(), PropertyFieldDefinition.build("second").name("Second").type(PropertyType.INTEGER).indicativeSize(5).build()) .build(); assertThat(def.type()).isEqualTo(PropertyType.PROPERTY_SET); assertThat(def.fields()).hasSize(2); assertThat(def.fields().get(0).key()).isEqualTo("first"); assertThat(def.fields().get(0).name()).isEqualTo("First"); assertThat(def.fields().get(0).description()).isEqualTo("Description"); assertThat(def.fields().get(0).type()).isEqualTo(PropertyType.STRING); assertThat(def.fields().get(0).options()).containsOnly("A", "B"); assertThat(def.fields().get(0).indicativeSize()).isEqualTo(20); assertThat(def.fields().get(1).key()).isEqualTo("second"); assertThat(def.fields().get(1).name()).isEqualTo("Second"); assertThat(def.fields().get(1).type()).isEqualTo(PropertyType.INTEGER); assertThat(def.fields().get(1).options()).isEmpty(); assertThat(def.fields().get(1).indicativeSize()).isEqualTo(5); }
static List<PropertyFieldDefinition> create(PropertyField[] fields) { List<PropertyFieldDefinition> definitions = new ArrayList<>(); for (PropertyField field : fields) { definitions.add(PropertyFieldDefinition.build(field.key()) .name(field.name()) .description(field.description()) .indicativeSize(field.indicativeSize()) .type(field.type()) .options(field.options()) .build()); } return definitions; }
.description("Pattern to match rules which should be ignored.") .type(PropertyType.STRING) .indicativeSize(LARGE_SIZE) .build(), PropertyFieldDefinition.build(RESOURCE_KEY) .description("Pattern to match files which should be ignored.") .type(PropertyType.STRING) .indicativeSize(LARGE_SIZE) .build() .description("If this regular expression is found in a file, then following lines are ignored until end of block.") .type(PropertyType.STRING) .indicativeSize(LARGE_SIZE) .build(), PropertyFieldDefinition.build(END_BLOCK_REGEXP) .description("If specified, this regular expression is used to determine the end of code blocks to ignore. If not, then block ends at the end of file.") .type(PropertyType.STRING) .indicativeSize(LARGE_SIZE) .build() .description("If this regular expression is found in a file, then the whole file is ignored.") .type(PropertyType.STRING) .indicativeSize(LARGE_SIZE) .build() .description("Pattern used to match rules which should be restricted.") .type(PropertyType.STRING)
.description("Pattern to match rules which should be ignored.") .type(PropertyType.STRING) .indicativeSize(LARGE_SIZE) .build(), PropertyFieldDefinition.build(RESOURCE_KEY) .description("Pattern to match files which should be ignored.") .type(PropertyType.STRING) .indicativeSize(LARGE_SIZE) .build() .description("If this regular expression is found in a file, then following lines are ignored until end of block.") .type(PropertyType.STRING) .indicativeSize(LARGE_SIZE) .build(), PropertyFieldDefinition.build(END_BLOCK_REGEXP) .description("If specified, this regular expression is used to determine the end of code blocks to ignore. If not, then block ends at the end of file.") .type(PropertyType.STRING) .indicativeSize(LARGE_SIZE) .build() .description("If this regular expression is found in a file, then the whole file is ignored.") .type(PropertyType.STRING) .indicativeSize(LARGE_SIZE) .build() .description("Pattern used to match rules which should be restricted.") .type(PropertyType.STRING)
static List<PropertyFieldDefinition> create(PropertyField[] fields) { List<PropertyFieldDefinition> definitions = newArrayList(); for (PropertyField field : fields) { definitions.add(PropertyFieldDefinition.build(field.key()) .name(field.name()) .description(field.description()) .indicativeSize(field.indicativeSize()) .type(field.type()) .options(field.options()) .build() ); } return definitions; }
static List<PropertyFieldDefinition> create(PropertyField[] fields) { List<PropertyFieldDefinition> definitions = new ArrayList<>(); for (PropertyField field : fields) { definitions.add(PropertyFieldDefinition.build(field.key()) .name(field.name()) .description(field.description()) .indicativeSize(field.indicativeSize()) .type(field.type()) .options(field.options()) .build()); } return definitions; }