Skip to content

Commit

Permalink
Minor changes to registry serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-weber committed Apr 30, 2024
1 parent 6d808f0 commit 0493627
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ public ObjectNode serialize( ObjectMapper mapper ) {
for ( Parameter p : posParams ) {
posArr.add( p.serialize( mapper ) );
}
if ( !posArr.isEmpty() && canUnpackValues() ) {
((ObjectNode) posArr.get( 0 )).put( "canUnpackValues", true);
}
node.set( "posParams", posArr );

ArrayNode kwArr = mapper.createArrayNode();
Expand Down Expand Up @@ -308,6 +311,7 @@ public ObjectNode serialize( ObjectMapper mapper ) {
node.put( "requiresAlias", requiresAlias );
if ( !isPositional() ) {
node.set( "defaultValue", defaultValue.serializeWrapped( null, List.of(), mapper ) );
node.put( "defaultPolyAlg", defaultValue.toPolyAlg( null, List.of() ) );
}
node.put( "isEnum", type.isEnum() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,16 @@ private static boolean isCastWithSameName( String exp, String alias ) {
/**
* Joins the values for a multivalued attribute into a single string.
* If values contains more than one element, the returned string is surrounded with brackets to represent a list.
* An empty list is indicated with {@code "[]"}.
*
* @param values the values to be joined
* @param omitBrackets whether the surrounding brackets in the case of multiple values should be omitted
* @return a string either representing a list containing all entries of values or a single value if values is of size 1
*/
public static String joinMultiValued( List<String> values, boolean omitBrackets ) {
if ( values.isEmpty() ) {
return "[]";
}
String str = String.join( ", ", values );
return (omitBrackets || values.size() <= 1) ? str : "[" + str + "]";
}
Expand Down

0 comments on commit 0493627

Please sign in to comment.