/*
 * Copyright 2014 Effektif GmbH.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.effektif.workflow.api.workflow;

import com.effektif.workflow.api.types.DataType;



/**
 * A binding stores a value for an activity input parameter, such as a process
 * variable.
 *
 * <p>
 * A binding specifies a value in one of two ways:
 * </p>
 * <ol>
 * <li>a fixed value</li>
 * <li>an expression - see <a href="https://github.com/effektif/effektif/wiki/Expressions">Expressions</a>.</li>
 * </ol>
 *
 * @author Tom Baeyens
 */
public class Binding<T> {

  protected T value;
  protected DataType dataType;
  protected String expression;

  /**
   * the fixed value. When serializing and deserializing, the type for this
   * value will be automatically initialized. This value is mutually exclusive
   * with variableId and expression
   */
  public T getValue() {
    return this.value;
  }
  /**
   * the fixed value. When serializing and deserializing, the type for this
   * value will be automatically initialized. This value is mutually exclusive
   * with expression
   */
  public void setValue(T value) {
    this.value = value;
  }
  /**
   * the fixed value. When serializing and deserializing, the type for this
   * value will be automatically initialized. This value is mutually exclusive
   * with variableId and expression
   */
  public Binding<T> value(T value) {
    this.value = value;
    return this;
  }
  
  /** specifies how a dynamic value is to be fetched from the variables. 
   * @see https://github.com/effektif/effektif/wiki/Expressions */
  public String getExpression() {
    return this.expression;
  }
  /** specifies how a dynamic value is to be fetched from the variables. 
   * @see https://github.com/effektif/effektif/wiki/Expressions */
  public void setExpression(String expression) {
    this.expression = expression;
  }
  /** specifies how a dynamic value is to be fetched from the variables. 
   * @see https://github.com/effektif/effektif/wiki/Expressions */
  public Binding expression(String expression) {
    this.expression = expression;
    return this;
  }

  public boolean isEmpty() {
    return value == null && expression == null;
  }
  
  public DataType getDataType() {
    return dataType;
  }
  
  public void setDataType(DataType dataType) {
    this.dataType = dataType;
  }
  @Override
  public String toString() {
    return "Binding[value=" + value + ",dataType=" + dataType + ",expression=" + expression + "]";
  }
  
  
}

@@ -683,17 +683,16 @@
 Type;%0A%0A%0A
-%0A
 /**%0A * A
@@ -1147,32 +1147,40 @@
 ion;%0A%0A  /**%0A   *
+ Returns
  the fixed value
@@ -1320,39 +1320,24 @@
 e%0A   * with 
-variableId and 
 expression%0A 
@@ -1326,32 +1326,33 @@
  with expression
+.
 %0A   */%0A  public 
@@ -1385,32 +1385,33 @@
 this.value;%0A  %7D%0A
+%0A
   /**%0A   * the f
@@ -1396,32 +1396,37 @@
 %0A  %7D%0A%0A  /**%0A   *
+ Sets
  the fixed value
@@ -1572,32 +1572,33 @@
  with expression
+.
 %0A   */%0A  public 
@@ -1646,24 +1646,25 @@
  value;%0A  %7D%0A
+%0A
   /**%0A   * t
@@ -1661,16 +1661,21 @@
 /**%0A   *
+ Sets
  the fix
@@ -1831,19 +1831,8 @@
 ith 
-variableId 
 and 
@@ -2132,32 +2132,33 @@
 expression;%0A  %7D%0A
+%0A
   /** specifies 
@@ -2369,16 +2369,17 @@
 on;%0A  %7D%0A
+%0A
   /** sp
@@ -2434,33 +2434,32 @@
 m the variables.
- 
 %0A   * @see https
@@ -2986,16 +2986,10 @@
 %5D%22;%0A
+
   %7D%0A
-  %0A  %0A
 %7D%0A

Add Javadoc