Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,8 @@ java_library(
name = "operator",
exports = ["//common/src/main/java/dev/cel/common:operator"],
)

cel_android_library(
name = "operator_android",
exports = ["//common/src/main/java/dev/cel/common:operator_android"],
)
8 changes: 8 additions & 0 deletions common/src/main/java/dev/cel/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,11 @@ java_library(
],
deps = ["@maven//:com_google_guava_guava"],
)

cel_android_library(
name = "operator_android",
srcs = ["Operator.java"],
tags = [
],
deps = ["@maven_android//:com_google_guava_guava"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package dev.cel.runtime.standard;

import static dev.cel.common.Operator.ADD;
import static dev.cel.runtime.standard.ArithmeticHelpers.getArithmeticErrorCode;

import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -170,6 +171,6 @@ public CelFunctionBinding newFunctionBinding(
}

private AddOperator(ImmutableSet<CelStandardOverload> overloads) {
super(overloads);
super(ADD.getFunction(), overloads);
}
}
32 changes: 32 additions & 0 deletions runtime/src/main/java/dev/cel/runtime/standard/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ java_library(
":arithmetic_helpers",
":standard_function",
":standard_overload",
"//common:operator",
"//common:options",
"//common:runtime_exception",
"//common/internal:date_time_helpers",
Expand All @@ -70,6 +71,7 @@ cel_android_library(
":arithmetic_helpers",
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//common:runtime_exception",
"//common/internal:date_time_helpers_android",
Expand All @@ -92,6 +94,7 @@ java_library(
":arithmetic_helpers",
":standard_function",
":standard_overload",
"//common:operator",
"//common:options",
"//common:runtime_exception",
"//common/internal:date_time_helpers",
Expand All @@ -113,6 +116,7 @@ cel_android_library(
":arithmetic_helpers",
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//common:runtime_exception",
"//common/internal:date_time_helpers_android",
Expand Down Expand Up @@ -364,6 +368,7 @@ java_library(
],
deps = [
":standard_overload",
"//common:operator",
"//common:options",
"//runtime:function_binding",
"//runtime:runtime_equality",
Expand All @@ -380,6 +385,7 @@ cel_android_library(
deps = [
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//runtime:function_binding_android",
"//runtime:runtime_equality_android",
Expand Down Expand Up @@ -742,6 +748,7 @@ java_library(
],
deps = [
":standard_overload",
"//common:operator",
"//common:options",
"//common/internal:comparison_functions",
"//common/internal:proto_time_utils",
Expand All @@ -763,6 +770,7 @@ cel_android_library(
deps = [
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//common/internal:comparison_functions_android",
"//common/internal:proto_time_utils_android",
Expand All @@ -782,6 +790,7 @@ java_library(
],
deps = [
":standard_overload",
"//common:operator",
"//common:options",
"//common/internal:comparison_functions",
"//common/internal:proto_time_utils",
Expand All @@ -803,6 +812,7 @@ cel_android_library(
deps = [
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//common/internal:comparison_functions_android",
"//common/internal:proto_time_utils_android",
Expand All @@ -822,6 +832,7 @@ java_library(
],
deps = [
":standard_overload",
"//common:operator",
"//common:options",
"//runtime:function_binding",
"//runtime:runtime_equality",
Expand All @@ -838,6 +849,7 @@ cel_android_library(
deps = [
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//runtime:function_binding_android",
"//runtime:runtime_equality_android",
Expand All @@ -852,6 +864,7 @@ java_library(
],
deps = [
":standard_overload",
"//common:operator",
"//common:options",
"//runtime:function_binding",
"//runtime:runtime_equality",
Expand All @@ -869,6 +882,7 @@ cel_android_library(
deps = [
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//runtime:function_binding_android",
"//runtime:runtime_equality_android",
Expand Down Expand Up @@ -924,6 +938,7 @@ java_library(
],
deps = [
":standard_overload",
"//common:operator",
"//common:options",
"//common/internal:comparison_functions",
"//common/internal:proto_time_utils",
Expand All @@ -945,6 +960,7 @@ cel_android_library(
deps = [
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//common/internal:comparison_functions_android",
"//common/internal:proto_time_utils_android",
Expand All @@ -964,6 +980,7 @@ java_library(
],
deps = [
":standard_overload",
"//common:operator",
"//common:options",
"//common/internal:comparison_functions",
"//common/internal:proto_time_utils",
Expand All @@ -985,6 +1002,7 @@ cel_android_library(
deps = [
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//common/internal:comparison_functions_android",
"//common/internal:proto_time_utils_android",
Expand All @@ -1004,6 +1022,7 @@ java_library(
],
deps = [
":standard_overload",
"//common:operator",
"//common:options",
"//runtime:function_binding",
"//runtime:runtime_equality",
Expand All @@ -1020,6 +1039,7 @@ cel_android_library(
deps = [
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//runtime:function_binding_android",
"//runtime:runtime_equality_android",
Expand Down Expand Up @@ -1071,6 +1091,7 @@ java_library(
deps = [
":arithmetic_helpers",
":standard_overload",
"//common:operator",
"//common:options",
"//common:runtime_exception",
"//runtime:function_binding",
Expand All @@ -1090,6 +1111,7 @@ cel_android_library(
":arithmetic_helpers",
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//common:runtime_exception",
"//runtime:function_binding_android",
Expand All @@ -1107,6 +1129,7 @@ java_library(
deps = [
":arithmetic_helpers",
":standard_overload",
"//common:operator",
"//common:options",
"//common:runtime_exception",
"//runtime:function_binding",
Expand All @@ -1126,6 +1149,7 @@ cel_android_library(
":arithmetic_helpers",
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//common:runtime_exception",
"//runtime:function_binding_android",
Expand All @@ -1143,6 +1167,7 @@ java_library(
deps = [
":arithmetic_helpers",
":standard_overload",
"//common:operator",
"//common:options",
"//common:runtime_exception",
"//runtime:function_binding",
Expand All @@ -1162,6 +1187,7 @@ cel_android_library(
":arithmetic_helpers",
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//common:runtime_exception",
"//runtime:function_binding_android",
Expand All @@ -1179,6 +1205,7 @@ java_library(
deps = [
":arithmetic_helpers",
":standard_overload",
"//common:operator",
"//common:options",
"//common:runtime_exception",
"//runtime:function_binding",
Expand All @@ -1198,6 +1225,7 @@ cel_android_library(
":arithmetic_helpers",
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//common:runtime_exception",
"//runtime:function_binding_android",
Expand All @@ -1214,6 +1242,7 @@ java_library(
],
deps = [
":standard_overload",
"//common:operator",
"//common:options",
"//runtime:function_binding",
"//runtime:runtime_equality",
Expand All @@ -1230,6 +1259,7 @@ cel_android_library(
deps = [
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//runtime:function_binding_android",
"//runtime:runtime_equality_android",
Expand Down Expand Up @@ -1426,6 +1456,7 @@ java_library(
],
deps = [
":standard_overload",
"//common:operator",
"//common:options",
"//runtime:function_binding",
"//runtime:internal_function_binder",
Expand All @@ -1443,6 +1474,7 @@ cel_android_library(
deps = [
":standard_function_android",
":standard_overload_android",
"//common:operator_android",
"//common:options",
"//runtime:function_binding_android",
"//runtime:internal_function_binder_android",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ public CelFunctionBinding newFunctionBinding(
}

private BoolFunction(ImmutableSet<CelStandardOverload> overloads) {
super(overloads);
super("bool", overloads);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ public CelFunctionBinding newFunctionBinding(
}

private BytesFunction(ImmutableSet<CelStandardOverload> overloads) {
super(overloads);
super("bytes", overloads);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

package dev.cel.runtime.standard;

import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Preconditions.checkArgument;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.errorprone.annotations.Immutable;
import dev.cel.common.CelOptions;
Expand All @@ -28,6 +29,7 @@
*/
@Immutable
public abstract class CelStandardFunction {
private final String name;
private final ImmutableSet<CelStandardOverload> overloads;

public ImmutableSet<CelFunctionBinding> newFunctionBindings(
Expand All @@ -40,8 +42,10 @@ public ImmutableSet<CelFunctionBinding> newFunctionBindings(
return builder.build();
}

CelStandardFunction(ImmutableSet<CelStandardOverload> overloads) {
checkState(!overloads.isEmpty(), "At least 1 overload must be provided.");
CelStandardFunction(String name, ImmutableSet<CelStandardOverload> overloads) {
checkArgument(!Strings.isNullOrEmpty(name), "Function name must be provided.");
checkArgument(!overloads.isEmpty(), "At least 1 overload must be provided.");
this.overloads = overloads;
this.name = name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ public CelFunctionBinding newFunctionBinding(
}

private ContainsFunction(ImmutableSet<CelStandardOverload> overloads) {
super(overloads);
super("contains", overloads);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package dev.cel.runtime.standard;

import static dev.cel.common.Operator.DIVIDE;
import static dev.cel.runtime.standard.ArithmeticHelpers.getArithmeticErrorCode;

import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -90,6 +91,6 @@ public CelFunctionBinding newFunctionBinding(
}

private DivideOperator(ImmutableSet<CelStandardOverload> overloads) {
super(overloads);
super(DIVIDE.getFunction(), overloads);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ public CelFunctionBinding newFunctionBinding(
}

private DoubleFunction(ImmutableSet<CelStandardOverload> overloads) {
super(overloads);
super("double", overloads);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ public CelFunctionBinding newFunctionBinding(
}

private DurationFunction(ImmutableSet<CelStandardOverload> overloads) {
super(overloads);
super("duration", overloads);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ public CelFunctionBinding newFunctionBinding(
}

private DynFunction(ImmutableSet<CelStandardOverload> overloads) {
super(overloads);
super("dyn", overloads);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ public CelFunctionBinding newFunctionBinding(
}

private EndsWithFunction(ImmutableSet<CelStandardOverload> overloads) {
super(overloads);
super("endsWith", overloads);
}
}
Loading
Loading