package edu.washington.escience.myria.api.encoding;

import java.util.List;

import com.google.common.collect.ImmutableList;

import edu.washington.escience.myria.Schema;
import edu.washington.escience.myria.Type;
import edu.washington.escience.myria.expression.Expression;
import edu.washington.escience.myria.expression.ExpressionOperator;

/**
 * Holds the AST and output name.
 */
public class ExpressionEncoding extends MyriaApiEncoding {
  public String outputName;
  public ExpressionOperator rootExpressionOperator;

  private static final ImmutableList<String> requiredFields = ImmutableList.of("outputName", "rootExpressionOperator");

  public ExpressionEncoding() {
    super();
  }

  public ExpressionEncoding(String outputName, ExpressionOperator rootExpressionOperator) {
    this.outputName = outputName;
    this.rootExpressionOperator = rootExpressionOperator;
  }

  @Override
  protected List<String> getRequiredFields() {
    return requiredFields;
  }

  /**
   * @param schema the input schema
   * @return the type of the output of the expression
   */
  public Type getOutputType(Schema schema) {
    return rootExpressionOperator.getOutputType(schema);
  }

  public Expression construct() {
    return new Expression(outputName, rootExpressionOperator.getJavaString(), ImmutableList
        .copyOf(rootExpressionOperator.getVariables()), this);
  }
}
@@ -66,24 +66,78 @@
 util.List;%0A%0A
+import com.fasterxml.jackson.annotation.JsonProperty;%0A
 import com.g
@@ -168,24 +168,24 @@
 utableList;%0A
-
 %0Aimport edu.
@@ -439,16 +439,22 @@
 %0Apublic 
+final 
 class Ex
@@ -499,22 +499,45 @@
 ing %7B%0A  
-public
+@JsonProperty%0A  private final
  String 
@@ -548,24 +548,48 @@
 utName;%0A
+%0A
   
-public
+@JsonProperty%0A  private final
  Express
@@ -786,15 +786,60 @@
     
-super()
+outputName = null;%0A    rootExpressionOperator = null
 ;%0A  

Make ExpressionEncoding final since we pass it to the constructor of Expression