Skip to content

Commit

Permalink
Add preconditions
Browse files Browse the repository at this point in the history
  • Loading branch information
martint committed Oct 18, 2012
1 parent 7835cbc commit d1e1448
Show file tree
Hide file tree
Showing 21 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

import java.util.List;

Expand All @@ -13,6 +14,9 @@ public class AliasedRelation

public AliasedRelation(Relation relation, String alias, List<String> columnNames)
{
Preconditions.checkNotNull(relation, "relation is null");
Preconditions.checkNotNull(alias, " is null");

this.relation = relation;
this.alias = alias;
this.columnNames = columnNames;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class BetweenPredicate
extends Expression
Expand All @@ -11,6 +12,10 @@ public class BetweenPredicate

public BetweenPredicate(Expression value, Expression min, Expression max)
{
Preconditions.checkNotNull(value, "value is null");
Preconditions.checkNotNull(min, "min is null");
Preconditions.checkNotNull(max, "max is null");

this.value = value;
this.min = min;
this.max = max;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;

import java.util.List;
Expand All @@ -12,6 +13,8 @@ public class CoalesceExpression

public CoalesceExpression(List<Expression> operands)
{
Preconditions.checkNotNull(operands, "operands is null");

this.operands = ImmutableList.copyOf(operands);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class ComparisonExpression
extends Expression
Expand Down Expand Up @@ -32,6 +33,10 @@ public String getValue()

public ComparisonExpression(Type type, Expression left, Expression right)
{
Preconditions.checkNotNull(type, "type is null");
Preconditions.checkNotNull(left, "left is null");
Preconditions.checkNotNull(right, "right is null");

this.type = type;
this.left = left;
this.right = right;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/facebook/presto/sql/tree/DateLiteral.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class DateLiteral
extends Literal
Expand All @@ -9,6 +10,7 @@ public class DateLiteral

public DateLiteral(String value)
{
Preconditions.checkNotNull(value, "value is null");
this.value = value;
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/facebook/presto/sql/tree/DoubleLiteral.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class DoubleLiteral
extends Literal
Expand All @@ -9,6 +10,7 @@ public class DoubleLiteral

public DoubleLiteral(String value)
{
Preconditions.checkNotNull(value, "value is null");
this.value = value;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class ExistsPredicate
extends Expression
Expand All @@ -9,6 +10,7 @@ public class ExistsPredicate

public ExistsPredicate(Query subquery)
{
Preconditions.checkNotNull(subquery, "subquery is null");
this.subquery = subquery;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class IntervalLiteral
extends Literal
Expand All @@ -16,6 +17,9 @@ public enum Sign

public IntervalLiteral(String value, String type, Sign sign)
{
Preconditions.checkNotNull(value, "value is null");
Preconditions.checkNotNull(type, "type is null");

this.value = value;
this.type = type;
this.sign = sign;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class IsNotNullPredicate
extends Expression
Expand All @@ -9,6 +10,7 @@ public class IsNotNullPredicate

public IsNotNullPredicate(Expression value)
{
Preconditions.checkNotNull(value, "value is null");
this.value = value;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class IsNullPredicate
extends Expression
Expand All @@ -9,6 +10,7 @@ public class IsNullPredicate

public IsNullPredicate(Expression value)
{
Preconditions.checkNotNull(value, "value is null");
this.value = value;
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/facebook/presto/sql/tree/Join.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class Join
extends Relation
{
public Join(Type type, Relation left, Relation right, JoinCriteria criteria)
{
Preconditions.checkNotNull(left, "left is null");
Preconditions.checkNotNull(right, "right is null");

this.type = type;
this.left = left;
this.right = right;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/facebook/presto/sql/tree/LikePredicate.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class LikePredicate
extends Expression
Expand All @@ -10,6 +11,9 @@ public class LikePredicate
private final Expression escape;

public LikePredicate(Expression value, Expression pattern, Expression escape) {
Preconditions.checkNotNull(value, "value is null");
Preconditions.checkNotNull(pattern, "pattern is null");

this.value = value;
this.pattern = pattern;
this.escape = escape;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class LogicalBinaryExpression
extends Expression
Expand All @@ -16,6 +17,10 @@ public enum Type

public LogicalBinaryExpression(Type type, Expression left, Expression right)
{
Preconditions.checkNotNull(type, "type is null");
Preconditions.checkNotNull(left, "left is null");
Preconditions.checkNotNull(right, "right is null");

this.type = type;
this.left = left;
this.right = right;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/facebook/presto/sql/tree/LongLiteral.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class LongLiteral
extends Literal
Expand All @@ -9,6 +10,7 @@ public class LongLiteral

public LongLiteral(String value)
{
Preconditions.checkNotNull(value, "value is null");
this.value = value;
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/facebook/presto/sql/tree/NotExpression.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class NotExpression
extends Expression
Expand All @@ -9,6 +10,7 @@ public class NotExpression

public NotExpression(Expression value)
{
Preconditions.checkNotNull(value, "value is null");
this.value = value;
}

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/facebook/presto/sql/tree/Query.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

import java.util.List;

Expand All @@ -24,6 +25,12 @@ public Query(
List<SortItem> orderBy,
String limit)
{
Preconditions.checkNotNull(select, "select is null");
Preconditions.checkNotNull(from, "from is null");
Preconditions.checkArgument(!from.isEmpty(), "from is empty");
Preconditions.checkNotNull(groupBy, "groupBy is null");
Preconditions.checkNotNull(orderBy, "orderBy is null");

this.select = select;
this.from = from;
this.where = where;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;

import java.util.List;
Expand All @@ -13,6 +14,7 @@ public class SearchedCaseExpression

public SearchedCaseExpression(List<WhenClause> whenClauses, Expression defaultValue)
{
Preconditions.checkNotNull(whenClauses, "whenClauses is null");
this.whenClauses = ImmutableList.copyOf(whenClauses);
this.defaultValue = defaultValue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;

import java.util.List;
Expand All @@ -14,6 +15,9 @@ public class SimpleCaseExpression

public SimpleCaseExpression(Expression operand, List<WhenClause> whenClauses, Expression defaultValue)
{
Preconditions.checkNotNull(operand, "operand is null");
Preconditions.checkNotNull(whenClauses, "whenClauses is null");

this.operand = operand;
this.whenClauses = ImmutableList.copyOf(whenClauses);
this.defaultValue = defaultValue;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/facebook/presto/sql/tree/StringLiteral.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class StringLiteral
extends Literal
Expand All @@ -9,6 +10,7 @@ public class StringLiteral

public StringLiteral(String value)
{
Preconditions.checkNotNull(value, "value is null");
this.value = value;
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/facebook/presto/sql/tree/TimeLiteral.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class TimeLiteral
extends Literal
Expand All @@ -9,6 +10,7 @@ public class TimeLiteral

public TimeLiteral(String value)
{
Preconditions.checkNotNull(value, "value is null");
this.value = value;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.facebook.presto.sql.tree;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;

public class TimestampLiteral
extends Literal
Expand All @@ -9,6 +10,8 @@ public class TimestampLiteral

public TimestampLiteral(String value)
{
Preconditions.checkNotNull(value, "value is null");

this.value = value;
}

Expand Down

0 comments on commit d1e1448

Please sign in to comment.