Skip to content

Commit

Permalink
fixup! Make use of union types from blaze-domain for some numeric fun…
Browse files Browse the repository at this point in the history
…ctions
  • Loading branch information
beikov committed Feb 28, 2022
1 parent 3e2a203 commit abd052f
Show file tree
Hide file tree
Showing 22 changed files with 19,278 additions and 8,902 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public class BaseContributor implements DomainContributor, ExpressionServiceCont
public static final String DATE_TYPE_NAME = "Date";
public static final Class<?> DATE = LocalDate.class;

public static final String NUMERIC_OR_INTEGER_TYPE_NAME = NUMERIC_TYPE_NAME + "|" + INTEGER_TYPE_NAME;
public static final String INTEGER_OR_NUMERIC_TYPE_NAME = INTEGER_TYPE_NAME + "|" + NUMERIC_TYPE_NAME;

public static final BooleanLiteralResolver BOOLEAN_LITERAL_TYPE_RESOLVER = new BooleanLiteralResolverImpl();
public static final NumericLiteralResolver NUMERIC_LITERAL_TYPE_RESOLVER = new NumericLiteralResolverImpl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static void addFunction(DomainBuilder domainBuilder, ClassLoader classLoa
.withMetadata(new FunctionInvokerMetadataDefinition(INSTANCE))
.withMetadata(DocumentationMetadataDefinition.localized("ABS", classLoader))
.withExactArgumentCount(1)
.withArgument("number", BaseContributor.NUMERIC_OR_INTEGER_TYPE_NAME, DocumentationMetadataDefinition.localized("ABS_ARG", classLoader))
.withArgument("number", BaseContributor.INTEGER_OR_NUMERIC_TYPE_NAME, DocumentationMetadataDefinition.localized("ABS_ARG", classLoader))
.build();
domainBuilder.withFunctionTypeResolver("ABS", StaticDomainFunctionTypeResolvers.FIRST_ARGUMENT_TYPE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public static void addFunction(DomainBuilder domainBuilder, ClassLoader classLoa
domainBuilder.createFunction("ATAN2")
.withMetadata(new FunctionInvokerMetadataDefinition(INSTANCE))
.withMetadata(DocumentationMetadataDefinition.localized("ATAN2", classLoader))
.withArgument("y", BaseContributor.NUMERIC_OR_INTEGER_TYPE_NAME, DocumentationMetadataDefinition.localized("ATAN2_Y", classLoader))
.withArgument("x", BaseContributor.NUMERIC_OR_INTEGER_TYPE_NAME, DocumentationMetadataDefinition.localized("ATAN2_X", classLoader))
.withArgument("y", BaseContributor.INTEGER_OR_NUMERIC_TYPE_NAME, DocumentationMetadataDefinition.localized("ATAN2_Y", classLoader))
.withArgument("x", BaseContributor.INTEGER_OR_NUMERIC_TYPE_NAME, DocumentationMetadataDefinition.localized("ATAN2_X", classLoader))
.build();
domainBuilder.withFunctionTypeResolver("ATAN2", StaticDomainFunctionTypeResolvers.returning(BaseContributor.NUMERIC_TYPE_NAME));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void addFunction(DomainBuilder domainBuilder, ClassLoader classLoa
.withMetadata(new FunctionInvokerMetadataDefinition(INSTANCE))
.withMetadata(DocumentationMetadataDefinition.localized("CEIL", classLoader))
.withExactArgumentCount(1)
.withArgument("number", BaseContributor.NUMERIC_OR_INTEGER_TYPE_NAME, DocumentationMetadataDefinition.localized("CEIL_ARG", classLoader))
.withArgument("number", BaseContributor.INTEGER_OR_NUMERIC_TYPE_NAME, DocumentationMetadataDefinition.localized("CEIL_ARG", classLoader))
.build();
domainBuilder.withFunctionTypeResolver("CEIL", StaticDomainFunctionTypeResolvers.returning(BaseContributor.INTEGER_TYPE_NAME));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void addFunction(DomainBuilder domainBuilder, ClassLoader classLoa
.withMetadata(new FunctionInvokerMetadataDefinition(INSTANCE))
.withMetadata(DocumentationMetadataDefinition.localized("FLOOR", classLoader))
.withExactArgumentCount(1)
.withArgument("number", BaseContributor.NUMERIC_OR_INTEGER_TYPE_NAME, DocumentationMetadataDefinition.localized("FLOOR_ARG", classLoader))
.withArgument("number", BaseContributor.INTEGER_OR_NUMERIC_TYPE_NAME, DocumentationMetadataDefinition.localized("FLOOR_ARG", classLoader))
.build();
domainBuilder.withFunctionTypeResolver("FLOOR", StaticDomainFunctionTypeResolvers.returning(BaseContributor.INTEGER_TYPE_NAME));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static void addFunction(DomainBuilder domainBuilder, ClassLoader classLoa
.withMetadata(new FunctionInvokerMetadataDefinition(f))
.withMetadata(DocumentationMetadataDefinition.localized(f.name, classLoader))
.withExactArgumentCount(1)
.withArgument("number", BaseContributor.NUMERIC_OR_INTEGER_TYPE_NAME, DocumentationMetadataDefinition.localized(f.name + "_ARG", classLoader))
.withArgument("number", BaseContributor.INTEGER_OR_NUMERIC_TYPE_NAME, DocumentationMetadataDefinition.localized(f.name + "_ARG", classLoader))
.build();
domainBuilder.withFunctionTypeResolver(f.name, StaticDomainFunctionTypeResolvers.returning(BaseContributor.NUMERIC_TYPE_NAME));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public static void addFunction(DomainBuilder domainBuilder, ClassLoader classLoa
domainBuilder.createFunction("POW")
.withMetadata(new FunctionInvokerMetadataDefinition(INSTANCE))
.withMetadata(DocumentationMetadataDefinition.localized("POW", classLoader))
.withArgument("base", BaseContributor.NUMERIC_OR_INTEGER_TYPE_NAME, DocumentationMetadataDefinition.localized("POW_BASE", classLoader))
.withArgument("power", BaseContributor.NUMERIC_OR_INTEGER_TYPE_NAME, DocumentationMetadataDefinition.localized("POW_POWER", classLoader))
.withArgument("base", BaseContributor.INTEGER_OR_NUMERIC_TYPE_NAME, DocumentationMetadataDefinition.localized("POW_BASE", classLoader))
.withArgument("power", BaseContributor.INTEGER_OR_NUMERIC_TYPE_NAME, DocumentationMetadataDefinition.localized("POW_POWER", classLoader))
.build();
domainBuilder.withFunctionTypeResolver("POW", StaticDomainFunctionTypeResolvers.returning(BaseContributor.NUMERIC_TYPE_NAME));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ public Expression visitCollectionLiteral(PredicateParser.CollectionLiteralContex
if (literalList.isEmpty()) {
collectionDomainType = domainModel.getCollectionType(null);
} else {
collectionDomainType = domainModel.getCollectionType(literalList.get(0).getType());
collectionDomainType = domainModel.getCollectionType(literalList.get(0).getType().getName());
}

return new CollectionLiteral(literalList, literalFactory.ofCollectionValues(compileContext, collectionDomainType, literalList));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public MetadataDefinition<?> process(Class<?> annotatedClass, Method method, Ann
if (typeAdapter != null || collection) {
return typeAdapter;
}
if (typeName == null) {
return null;
}
DomainBuilder domainBuilder = serviceProvider.getService(DomainBuilder.class);
DomainTypeDefinition type = domainBuilder.getType(typeName);
if (type == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public MetadataDefinition<?> process(Class<?> annotatedClass, Method method, Par
if (typeAdapter != null || collection) {
return typeAdapter;
}
if (typeName == null) {
return null;
}
DomainBuilder domainBuilder = serviceProvider.getService(DomainBuilder.class);
DomainTypeDefinition type = domainBuilder.getType(typeName);
if (type == null) {
Expand Down
Loading

0 comments on commit abd052f

Please sign in to comment.