-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
8 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/edu/washington/escience/myria/expression/ConcatExpression.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package edu.washington.escience.myria.expression; | ||
|
||
import com.google.common.base.Preconditions; | ||
|
||
import edu.washington.escience.myria.Type; | ||
import edu.washington.escience.myria.expression.evaluate.ExpressionOperatorParameter; | ||
|
||
public class ConcatExpression extends BinaryExpression { | ||
/***/ | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* This is not really unused, it's used automagically by Jackson deserialization. | ||
*/ | ||
@SuppressWarnings("unused") | ||
private ConcatExpression() {} | ||
|
||
public ConcatExpression(final ExpressionOperator left, final ExpressionOperator right) { | ||
super(left, right); | ||
} | ||
|
||
@Override | ||
public Type getOutputType(ExpressionOperatorParameter parameters) { | ||
Preconditions.checkArgument( | ||
getChildren().size() == 2, "Concat function has to take 2 arguments."); | ||
Preconditions.checkArgument( | ||
getChildren().get(0).getOutputType(parameters) == Type.STRING_TYPE, | ||
"The first argument of concat has to be STRING."); | ||
Preconditions.checkArgument( | ||
getChildren().get(1).getOutputType(parameters) == Type.STRING_TYPE, | ||
"The second argument of concat has to be STRING."); | ||
return Type.STRING_TYPE; | ||
} | ||
|
||
@Override | ||
public String getJavaString(ExpressionOperatorParameter parameters) { | ||
return getInfixBinaryString("+", parameters); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters