Skip to content

Commit fe02b64

Browse files
l46kokcopybara-github
authored andcommitted
Remove deprecated dev.cel.runtime.CelRuntime.CelFunctionBinding
PiperOrigin-RevId: 735162133
1 parent 77d13cf commit fe02b64

File tree

2 files changed

+9
-73
lines changed

2 files changed

+9
-73
lines changed

runtime/src/main/java/dev/cel/runtime/CelRuntime.java

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import com.google.auto.value.AutoValue;
1818
import com.google.common.base.Preconditions;
19-
import com.google.common.collect.ImmutableList;
2019
import com.google.errorprone.annotations.CanIgnoreReturnValue;
2120
import com.google.errorprone.annotations.Immutable;
2221
import javax.annotation.concurrent.ThreadSafe;
@@ -227,65 +226,4 @@ static Program from(Interpretable interpretable, CelOptions options) {
227226
return new AutoValue_CelRuntime_Program(interpretable, options);
228227
}
229228
}
230-
231-
/**
232-
* Deprecated. Do not use.
233-
*
234-
* @deprecated {@link dev.cel.runtime.CelFunctionBinding} instead.
235-
* <p>TODO: Migrate users to dev.cel.runtime.CelFunctionBinding
236-
*/
237-
@Immutable
238-
@Deprecated
239-
final class CelFunctionBinding implements dev.cel.runtime.CelFunctionBinding {
240-
private final dev.cel.runtime.CelFunctionBinding functionBinding;
241-
242-
private CelFunctionBinding(dev.cel.runtime.CelFunctionBinding functionBinding) {
243-
this.functionBinding = functionBinding;
244-
}
245-
246-
@Override
247-
public String getOverloadId() {
248-
return functionBinding.getOverloadId();
249-
}
250-
251-
@Override
252-
public ImmutableList<Class<?>> getArgTypes() {
253-
return functionBinding.getArgTypes();
254-
}
255-
256-
@Override
257-
public CelFunctionOverload getDefinition() {
258-
return functionBinding.getDefinition();
259-
}
260-
261-
/**
262-
* Create a unary function binding from the {@code overloadId}, {@code arg}, and {@code impl}.
263-
*/
264-
public static <T> CelFunctionBinding from(
265-
String overloadId, Class<T> arg, CelFunctionOverload.Unary<T> impl) {
266-
return new CelFunctionBinding(dev.cel.runtime.CelFunctionBinding.from(overloadId, arg, impl));
267-
}
268-
269-
/**
270-
* Create a binary function binding from the {@code overloadId}, {@code arg1}, {@code arg2}, and
271-
* {@code impl}.
272-
*/
273-
public static <T1, T2> CelFunctionBinding from(
274-
String overloadId,
275-
Class<T1> arg1,
276-
Class<T2> arg2,
277-
CelFunctionOverload.Binary<T1, T2> impl) {
278-
return new CelFunctionBinding(
279-
dev.cel.runtime.CelFunctionBinding.from(overloadId, arg1, arg2, impl));
280-
}
281-
282-
/**
283-
* Create a function binding from the {@code overloadId}, {@code argTypes}, and {@code impl}.
284-
*/
285-
public static CelFunctionBinding from(
286-
String overloadId, Iterable<Class<?>> argTypes, CelFunctionOverload impl) {
287-
return new CelFunctionBinding(
288-
dev.cel.runtime.CelFunctionBinding.from(overloadId, argTypes, impl));
289-
}
290-
}
291229
}

runtime/src/main/java/dev/cel/runtime/CelRuntimeLegacyImpl.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public final class CelRuntimeLegacyImpl implements CelRuntime {
8484
// CEL-Internal-4
8585
private final ImmutableSet<CelRuntimeLibrary> celRuntimeLibraries;
8686

87-
private final ImmutableList<dev.cel.runtime.CelFunctionBinding> celFunctionBindings;
87+
private final ImmutableList<CelFunctionBinding> celFunctionBindings;
8888

8989
@Override
9090
public CelRuntime.Program createProgram(CelAbstractSyntaxTree ast) {
@@ -129,8 +129,7 @@ public static final class Builder implements CelRuntimeBuilder {
129129
// The following properties are for testing purposes only. Do not expose to public.
130130
@VisibleForTesting final ImmutableSet.Builder<FileDescriptor> fileTypes;
131131

132-
@VisibleForTesting
133-
final HashMap<String, dev.cel.runtime.CelFunctionBinding> customFunctionBindings;
132+
@VisibleForTesting final HashMap<String, CelFunctionBinding> customFunctionBindings;
134133

135134
@VisibleForTesting final ImmutableSet.Builder<CelRuntimeLibrary> celRuntimeLibraries;
136135

@@ -151,13 +150,12 @@ public CelRuntimeBuilder setOptions(CelOptions options) {
151150
}
152151

153152
@Override
154-
public CelRuntimeBuilder addFunctionBindings(dev.cel.runtime.CelFunctionBinding... bindings) {
153+
public CelRuntimeBuilder addFunctionBindings(CelFunctionBinding... bindings) {
155154
return addFunctionBindings(Arrays.asList(bindings));
156155
}
157156

158157
@Override
159-
public CelRuntimeBuilder addFunctionBindings(
160-
Iterable<dev.cel.runtime.CelFunctionBinding> bindings) {
158+
public CelRuntimeBuilder addFunctionBindings(Iterable<CelFunctionBinding> bindings) {
161159
bindings.forEach(o -> customFunctionBindings.putIfAbsent(o.getOverloadId(), o));
162160
return this;
163161
}
@@ -272,9 +270,9 @@ public CelRuntimeLegacyImpl build() {
272270
DynamicProto dynamicProto = DynamicProto.create(runtimeTypeFactory);
273271
RuntimeEquality runtimeEquality = ProtoMessageRuntimeEquality.create(dynamicProto, options);
274272

275-
ImmutableMap.Builder<String, dev.cel.runtime.CelFunctionBinding> functionBindingsBuilder =
273+
ImmutableMap.Builder<String, CelFunctionBinding> functionBindingsBuilder =
276274
ImmutableMap.builder();
277-
for (dev.cel.runtime.CelFunctionBinding standardFunctionBinding :
275+
for (CelFunctionBinding standardFunctionBinding :
278276
newStandardFunctionBindings(runtimeEquality)) {
279277
functionBindingsBuilder.put(
280278
standardFunctionBinding.getOverloadId(), standardFunctionBinding);
@@ -286,7 +284,7 @@ public CelRuntimeLegacyImpl build() {
286284
functionBindingsBuilder
287285
.buildOrThrow()
288286
.forEach(
289-
(String overloadId, dev.cel.runtime.CelFunctionBinding func) ->
287+
(String overloadId, CelFunctionBinding func) ->
290288
dispatcher.add(
291289
overloadId, func.getArgTypes(), (args) -> func.getDefinition().apply(args)));
292290

@@ -327,7 +325,7 @@ public CelRuntimeLegacyImpl build() {
327325
ImmutableList.copyOf(customFunctionBindings.values()));
328326
}
329327

330-
private ImmutableSet<dev.cel.runtime.CelFunctionBinding> newStandardFunctionBindings(
328+
private ImmutableSet<CelFunctionBinding> newStandardFunctionBindings(
331329
RuntimeEquality runtimeEquality) {
332330
CelStandardFunctions celStandardFunctions;
333331
if (standardEnvironmentEnabled) {
@@ -424,7 +422,7 @@ private CelRuntimeLegacyImpl(
424422
@Nullable CelValueProvider celValueProvider,
425423
ImmutableSet<FileDescriptor> fileDescriptors,
426424
ImmutableSet<CelRuntimeLibrary> celRuntimeLibraries,
427-
ImmutableList<dev.cel.runtime.CelFunctionBinding> celFunctionBindings) {
425+
ImmutableList<CelFunctionBinding> celFunctionBindings) {
428426
this.interpreter = interpreter;
429427
this.options = options;
430428
this.standardEnvironmentEnabled = standardEnvironmentEnabled;

0 commit comments

Comments
 (0)