Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
package dev.cel.checker;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static java.util.Arrays.stream;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Immutable;
Expand Down Expand Up @@ -599,6 +601,13 @@ public enum Size implements StandardOverload {
CelOverloadDecl.newMemberOverload("map_size", "map size", SimpleType.INT, MAP_OF_AB)),
;

private static final ImmutableMap<String, Size> ID_TO_ENUM =
stream(values()).collect(toImmutableMap(e -> e.celOverloadDecl().overloadId(), e -> e));

public static Optional<Size> fromOverloadId(String overloadId) {
return Optional.ofNullable(ID_TO_ENUM.get(overloadId));
}

private final CelOverloadDecl celOverloadDecl;

Size(CelOverloadDecl overloadDecl) {
Expand Down
Loading