Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Add SafeVarargs to Expression methods #11027

Merged
merged 1 commit into from
Jan 24, 2018
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 @@ -68,6 +68,7 @@ public class Expression<T> {
* @param operator the expression operator
* @param arguments expressions input
*/
@SafeVarargs
public Expression(@NonNull String operator, @Nullable Expression... arguments) {
this.operator = operator;
this.arguments = arguments;
Expand Down Expand Up @@ -157,7 +158,7 @@ Object toValue() {
* Is used for first parameter of {@link #interpolate(Expression, Expression, Stop...)}.
* </p>
*/
private static class Interpolator {
public static class Interpolator {
}

/**
Expand Down Expand Up @@ -587,6 +588,7 @@ public static Expression<Boolean> lte(@NonNull String compareOne, @NonNull Strin
* @param input expression input
* @return expression
*/
@SafeVarargs
public static Expression<Boolean> all(@NonNull Expression<Boolean>... input) {
return new Expression<>("all", input);
}
Expand All @@ -602,6 +604,7 @@ public static Expression<Boolean> all(@NonNull Expression<Boolean>... input) {
* @param input expression input
* @return expression
*/
@SafeVarargs
public static Expression<Boolean> any(@NonNull Expression<Boolean>... input) {
return new Expression<>("any", input);
}
Expand Down Expand Up @@ -632,6 +635,7 @@ public static Expression<Boolean> not(boolean input) {
* @param input expression input
* @return expression
*/
@SafeVarargs
public static Expression switchCase(@NonNull @Size(min = 1) Expression... input) {
return new Expression("case", input);
}
Expand Down Expand Up @@ -782,7 +786,7 @@ public static Expression get(@NonNull String input) {
* @param object an expression object
* @return expression
*/
public static Expression get(@NonNull Expression<String> key, @NonNull Expression<Object> object) {
public static Expression<Object> get(@NonNull Expression<String> key, @NonNull Expression<Object> object) {
return new Expression<>("get", key, object);
}

Expand All @@ -794,7 +798,7 @@ public static Expression get(@NonNull Expression<String> key, @NonNull Expressio
* @param object an expression object
* @return expression
*/
public static Expression get(@NonNull String key, @NonNull Expression<Object> object) {
public static Expression<Object> get(@NonNull String key, @NonNull Expression<Object> object) {
return get(literal(key), object);
}

Expand Down Expand Up @@ -897,6 +901,7 @@ public static Expression<Number> e() {
* @param numbers the numbers to calculate the sum for
* @return expression
*/
@SafeVarargs
public static Expression<Number> sum(@Size(min = 2) Expression<Number>... numbers) {
return new Expression<>("+", numbers);
}
Expand All @@ -922,6 +927,7 @@ public static Expression<Number> sum(@Size(min = 2) Number... numbers) {
* @param numbers the numbers to calculate the product for
* @return expression
*/
@SafeVarargs
public static Expression<Number> product(@Size(min = 2) Expression<Number>... numbers) {
return new Expression<>("*", numbers);
}
Expand Down Expand Up @@ -990,6 +996,7 @@ public static Expression<Number> subtract(@NonNull Number first, @NonNull Number
* @param second the second number
* @return expression
*/
@SuppressWarnings("unchecked")
public static Expression<Number> division(@NonNull Expression<Number> first, @NonNull Expression<Number> second) {
return new Expression<>("/", first, second);
}
Expand All @@ -1001,6 +1008,7 @@ public static Expression<Number> division(@NonNull Expression<Number> first, @No
* @param second the second number
* @return expression
*/
@SuppressWarnings("unchecked")
public static Expression<Number> division(@NonNull Number first, @NonNull Number second) {
return division(literal(first), literal(second));
}
Expand Down Expand Up @@ -1255,6 +1263,7 @@ public static Expression<Number> atan(@NonNull Number number) {
* @param numbers varargs of numbers to get the minimum from
* @return expression
*/
@SafeVarargs
public static Expression<Number> min(@Size(min = 1) Expression<Number>... numbers) {
return new Expression<>("min", numbers);
}
Expand All @@ -1280,6 +1289,7 @@ public static Expression<Number> min(@Size(min = 1) Number... numbers) {
* @param numbers varargs of numbers to get the maximum from
* @return expression
*/
@SafeVarargs
public static Expression<Number> max(@Size(min = 1) Expression<Number>... numbers) {
return new Expression<>("max", numbers);
}
Expand Down Expand Up @@ -1365,6 +1375,7 @@ public static Expression<String> downcase(@NonNull String input) {
* @param input expression input
* @return expression
*/
@SafeVarargs
public static Expression<String> concat(@NonNull Expression<String>... input) {
return new Expression<>("concat", input);
}
Expand Down Expand Up @@ -1522,6 +1533,7 @@ public static Expression<Color> toColor(@NonNull Expression input) {
* @param input expression input
* @return expression
*/
@SafeVarargs
public static Expression let(@Size(min = 1) Expression... input) {
return new Expression<>("let", input);
}
Expand Down Expand Up @@ -1582,6 +1594,7 @@ public static Stop stop(@NonNull Object stop, @NonNull Object value) {
* @param stops pair of input and output values
* @return expression
*/
@SafeVarargs
public static Expression step(@NonNull Number input, @NonNull Expression expression, Expression... stops) {
return step(literal(input), expression, stops);
}
Expand All @@ -1597,6 +1610,7 @@ public static Expression step(@NonNull Number input, @NonNull Expression express
* @param stops pair of input and output values
* @return expression
*/
@SafeVarargs
public static Expression step(@NonNull Expression<Number> input, @NonNull Expression expression, Expression... stops) {
return new Expression("step", join(new Expression[] {input, expression}, stops));
}
Expand All @@ -1612,6 +1626,7 @@ public static Expression step(@NonNull Expression<Number> input, @NonNull Expres
* @param stops pair of input and output values
* @return expression
*/
@SafeVarargs
public static Expression step(@NonNull Number input, @NonNull Expression expression, Stop... stops) {
Expression[] expressions = new Expression[stops.length * 2];
for (int i = 0; i < stops.length; i++) {
Expand All @@ -1632,6 +1647,7 @@ public static Expression step(@NonNull Number input, @NonNull Expression express
* @param stops pair of input and output values
* @return expression
*/
@SafeVarargs
public static Expression step(@NonNull Expression<Number> input, @NonNull Expression expression, Stop... stops) {
Expression[] expressions = new Expression[stops.length * 2];
for (int i = 0; i < stops.length; i++) {
Expand All @@ -1652,6 +1668,7 @@ public static Expression step(@NonNull Expression<Number> input, @NonNull Expres
* @param stops pair of input and output values
* @return expression
*/
@SafeVarargs
public static Expression interpolate(@NonNull Expression<Interpolator> interpolation,
@NonNull Expression<Number> number, Expression... stops) {
return new Expression("interpolate", join(new Expression[] {interpolation, number}, stops));
Expand All @@ -1668,6 +1685,7 @@ public static Expression interpolate(@NonNull Expression<Interpolator> interpola
* @param stops pair of input and output values
* @return expression
*/
@SafeVarargs
public static Expression interpolate(@NonNull Expression<Interpolator> interpolation,
@NonNull Expression<Number> number, Stop... stops) {
Expression[] expressions = new Expression[stops.length * 2];
Expand Down