Skip to content

Commit 93dc983

Browse files
l46kokcopybara-github
authored andcommitted
Introduce Java native type for Expr proto type
PiperOrigin-RevId: 508764346
1 parent d7d77a2 commit 93dc983

18 files changed

Lines changed: 978 additions & 89 deletions

File tree

.github/workflows/workflow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: CEL-Java CI
22
run-name: Workflow started by ${{ github.actor }}.
3-
on:
3+
on:
44
push:
55
branches:
66
- 'main'
@@ -32,5 +32,5 @@ jobs:
3232
- name: Bazel Output Version
3333
run: bazelisk --version
3434
- name: Bazel Test
35-
run: bazelisk test ...
35+
run: bazelisk test ... --test_output=errors
3636
- run: echo "🍏 This job's status is ${{ job.status }}."

WORKSPACE

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,9 @@ maven_install(
5858
"com.google.auto.value:auto-value:1.10.1",
5959
"com.google.auto.value:auto-value-annotations:1.10.1",
6060
"com.google.code.findbugs:annotations:3.0.1",
61+
"com.google.code.gson:gson:2.10.1",
6162
"com.google.errorprone:error_prone_annotations:2.16",
6263
"com.google.guava:guava:31.1-jre",
63-
"com.google.protobuf:protobuf-java:3.21.11",
64-
"com.google.protobuf:protobuf-java-util:3.21.11",
65-
"com.google.protobuf:protobuf-javalite:3.21.11",
6664
"com.google.re2j:re2j:1.7",
6765
"com.google.testparameterinjector:test-parameter-injector:1.10",
6866
"com.google.truth.extensions:truth-java8-extension:1.1.3",

common/src/main/java/dev/cel/common/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ java_library(
2323
"//common/src/main/java/dev/cel/common/types:cel_types",
2424
"//common/src/main/java/dev/cel/common/types:type_providers",
2525
"@com_google_googleapis//google/api/expr/v1alpha1:expr_java_proto",
26+
"@com_google_protobuf//:protobuf_java",
2627
"@maven//:com_google_errorprone_error_prone_annotations",
2728
"@maven//:com_google_guava_guava",
28-
"@maven//:com_google_protobuf_protobuf_java",
2929
],
3030
)
3131

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
11
package(default_visibility = [
22
"//:__subpackages__",
3-
"//common/src/main/java/dev/cel/common/expr:__pkg__",
3+
"//common/src/main/java/dev/cel/common/ast:__pkg__",
44
])
55

66
# keep sorted
77
EXPR_SOURCES = [
88
"CelConstant.java",
9+
"CelExpr.java",
910
"CelReference.java",
1011
]
1112

13+
# keep sorted
14+
EXPR_CONVERTER_SOURCES = [
15+
"CelExprConverter.java",
16+
]
17+
1218
java_library(
13-
name = "expr",
19+
name = "ast",
1420
srcs = EXPR_SOURCES,
1521
deps = [
1622
"//:auto_value",
1723
"//common/src/main/java/dev/cel/common/annotations",
24+
"@com_google_protobuf//:protobuf_java",
1825
"@com_google_protobuf//:struct_proto",
1926
"@maven//:com_google_errorprone_error_prone_annotations",
2027
"@maven//:com_google_guava_guava",
21-
"@maven//:com_google_protobuf_protobuf_javalite",
2228
"@maven//:org_jspecify_jspecify",
2329
],
2430
)
31+
32+
java_library(
33+
name = "expr_converter",
34+
srcs = EXPR_CONVERTER_SOURCES,
35+
deps = [
36+
":ast",
37+
"@com_google_googleapis//google/api/expr/v1alpha1:expr_java_proto",
38+
"@maven//:com_google_guava_guava",
39+
],
40+
)

common/src/main/java/dev/cel/common/expr/CelConstant.java renamed to common/src/main/java/dev/cel/common/ast/CelConstant.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package dev.cel.common.expr;
15+
package dev.cel.common.ast;
1616

1717
import com.google.auto.value.AutoOneOf;
18+
import com.google.common.primitives.UnsignedLong;
1819
import com.google.errorprone.annotations.Immutable;
1920
import com.google.protobuf.ByteString;
2021
import com.google.protobuf.NullValue;
@@ -48,39 +49,39 @@ public enum Kind {
4849

4950
public abstract long int64Value();
5051

51-
public abstract long uint64Value();
52+
public abstract UnsignedLong uint64Value();
5253

5354
public abstract double doubleValue();
5455

5556
public abstract String stringValue();
5657

5758
public abstract ByteString bytesValue();
5859

59-
public static CelConstant ofNullValue(NullValue value) {
60+
public static CelConstant ofValue(NullValue value) {
6061
return AutoOneOf_CelConstant.nullValue(value);
6162
}
6263

63-
public static CelConstant ofBooleanValue(boolean value) {
64+
public static CelConstant ofValue(boolean value) {
6465
return AutoOneOf_CelConstant.booleanValue(value);
6566
}
6667

67-
public static CelConstant ofInt64Value(long value) {
68+
public static CelConstant ofValue(long value) {
6869
return AutoOneOf_CelConstant.int64Value(value);
6970
}
7071

71-
public static CelConstant ofUInt64Value(long value) {
72+
public static CelConstant ofValue(UnsignedLong value) {
7273
return AutoOneOf_CelConstant.uint64Value(value);
7374
}
7475

75-
public static CelConstant ofDoubleValue(double value) {
76+
public static CelConstant ofValue(double value) {
7677
return AutoOneOf_CelConstant.doubleValue(value);
7778
}
7879

79-
public static CelConstant ofStringValue(String value) {
80+
public static CelConstant ofValue(String value) {
8081
return AutoOneOf_CelConstant.stringValue(value);
8182
}
8283

83-
public static CelConstant ofBytesValue(ByteString value) {
84+
public static CelConstant ofValue(ByteString value) {
8485
return AutoOneOf_CelConstant.bytesValue(value);
8586
}
8687
}

0 commit comments

Comments
 (0)