Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated create methods #325

Merged
1 commit merged into from
May 6, 2024
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
67 changes: 6 additions & 61 deletions common/src/main/java/dev/cel/common/ast/CelExpr.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.CheckReturnValue;
import com.google.errorprone.annotations.Immutable;
import com.google.errorprone.annotations.InlineMe;
import dev.cel.common.ast.CelExpr.ExprKind.Kind;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -90,32 +89,14 @@ public CelCall call() {
return exprKind().call();
}

/**
* @deprecated Use {@link #list()} instead.
*/
@Deprecated
@InlineMe(replacement = "this.list()")
public final CelList createList() {
return list();
}

/**
* {@inheritDoc}
*
* @throws UnsupportedOperationException if expression is not {@link Kind#LIST}.
*/
@Override
public CelList list() {
return exprKind().createList();
}

/**
* @deprecated Use {@link #list()} instead.
*/
@Deprecated
@InlineMe(replacement = "this.struct()")
public final CelStruct createStruct() {
return struct();
return exprKind().list();
}

/**
Expand All @@ -125,16 +106,7 @@ public final CelStruct createStruct() {
*/
@Override
public CelStruct struct() {
return exprKind().createStruct();
}

/**
* @deprecated Use {@link #list()} instead.
*/
@Deprecated
@InlineMe(replacement = "this.map()")
public final CelMap createMap() {
return map();
return exprKind().struct();
}

/**
Expand All @@ -144,7 +116,7 @@ public final CelMap createMap() {
*/
@Override
public CelMap map() {
return exprKind().createMap();
return exprKind().map();
}

/**
Expand Down Expand Up @@ -203,7 +175,7 @@ public CelCall callOrDefault() {
*/
public CelList listOrDefault() {
return exprKind().getKind().equals(ExprKind.Kind.LIST)
? exprKind().createList()
? exprKind().list()
: CelList.newBuilder().build();
}

Expand All @@ -213,7 +185,7 @@ public CelList listOrDefault() {
*/
public CelStruct structOrDefault() {
return exprKind().getKind().equals(ExprKind.Kind.STRUCT)
? exprKind().createStruct()
? exprKind().struct()
: CelStruct.newBuilder().build();
}

Expand All @@ -223,7 +195,7 @@ public CelStruct structOrDefault() {
*/
public CelMap mapOrDefault() {
return exprKind().getKind().equals(ExprKind.Kind.MAP)
? exprKind().createMap()
? exprKind().map()
: CelMap.newBuilder().build();
}

Expand Down Expand Up @@ -405,37 +377,10 @@ public enum Kind {

public abstract CelList list();

/**
* @deprecated Use {@link #list()} instead.
*/
@Deprecated
@InlineMe(replacement = "this.list()")
public final CelList createList() {
return list();
}

public abstract CelStruct struct();

/**
* @deprecated Use {@link #struct()} instead.
*/
@Deprecated
@InlineMe(replacement = "this.struct()")
public final CelStruct createStruct() {
return struct();
}

public abstract CelMap map();

/**
* @deprecated Use {@link #map()} instead.
*/
@Deprecated
@InlineMe(replacement = "this.map()")
public final CelMap createMap() {
return map();
}

public abstract CelComprehension comprehension();
}

Expand Down
4 changes: 2 additions & 2 deletions common/src/main/java/dev/cel/common/ast/CelExprConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ public static Expr fromCelExpr(CelExpr celExpr) {
.addAllOptionalIndices(celCreateList.optionalIndices()))
.build();
case STRUCT:
return expr.setStructExpr(celStructToExprStruct(celExprKind.createStruct())).build();
return expr.setStructExpr(celStructToExprStruct(celExprKind.struct())).build();
case MAP:
return expr.setStructExpr(celMapToExprStruct(celExprKind.createMap())).build();
return expr.setStructExpr(celMapToExprStruct(celExprKind.map())).build();
case COMPREHENSION:
CelExpr.CelComprehension celComprehension = celExprKind.comprehension();
return expr.setComprehensionExpr(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ public static Expr fromCelExpr(CelExpr celExpr) {
.addAllOptionalIndices(celCreateList.optionalIndices()))
.build();
case STRUCT:
return expr.setStructExpr(celStructToExprStruct(celExprKind.createStruct())).build();
return expr.setStructExpr(celStructToExprStruct(celExprKind.struct())).build();
case MAP:
return expr.setStructExpr(celMapToExprStruct(celExprKind.createMap())).build();
return expr.setStructExpr(celMapToExprStruct(celExprKind.map())).build();
case COMPREHENSION:
CelExpr.CelComprehension celComprehension = celExprKind.comprehension();
return expr.setComprehensionExpr(
Expand Down
Loading