Skip to content

Commit

Permalink
Add conversion for PropertyBuilder arrays
Browse files Browse the repository at this point in the history
Signed-off-by: lisrte <[email protected]>
  • Loading branch information
Lisrte committed Jun 5, 2024
1 parent c972518 commit d71bac7
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ public Property build() {
return switch (collectionType) {
case SINGLE -> new Property(name, type.isConversionFree() ? value : type.convertValue(value), type.getPropertyClass());
case LIST -> new Property(name, type.isConversionFree() ? values : values.stream().map(v -> type.convertValue(v)).toList(), Collection.class);
case LIST_ARRAY -> new Property(name, arrays.toArray(new List[0]), Collection[].class);
case LIST_ARRAY -> new Property(name, type.isConversionFree() ?
arrays.toArray(List[]::new) :
arrays.stream().map(vl -> vl.stream().map(v -> type.convertValue(v)).toList()).toArray(List[]::new),
Collection[].class);
};
}

Expand All @@ -48,6 +51,7 @@ public PropertyBuilder name(String name) {
}

public PropertyBuilder value(String value) {
collectionType = CollectionType.SINGLE;
this.value = value;
return this;
}
Expand Down

0 comments on commit d71bac7

Please sign in to comment.