class SetAttributeActionConfig implements ActionConfig {

   @Override
   public StatefulAction createAction(Map<String, Object> variables) {
      Preconditions.checkState(address != null, "Must specify an address");
      Preconditions.checkState(attributeName != null, "Must specify an attributeName");
      Preconditions.checkState(attributeValue != null, "Must specify an attributeValue");
      Preconditions.checkState(attributeType != null, "Must specify an attributeType");
      SetAndRestore action = null;
      if(reevaluateCondition) {
    	  action = new ConditionalSetAndRestore(
 		         FunctionFactory.toActionContextFunction(
 		               TemplatedValue.transform(
 		                     FunctionFactory.INSTANCE.getToAddress(), 
 		                     address.toTemplate()
 		               )
 		         ),
 		         FunctionFactory.INSTANCE.createConstant(attributeName),
 		         FunctionFactory.toActionContextFunction(
 		               TemplatedValue.transform(
 		                     FunctionFactory.createCoerceFunction(attributeType), 
 		                     attributeValue.toTemplate()
 		               )
 		         ),
 		         unit.toMillis(duration),
 		         conditionQuery==null?null:FunctionFactory.toModelPredicate(this.conditionQuery.toTemplate(), variables)
 		      );
      }else {    	  
    	  action = new SetAndRestore(
    		         FunctionFactory.toActionContextFunction(
    		               TemplatedValue.transform(
    		                     FunctionFactory.INSTANCE.getToAddress(), 
    		                     address.toTemplate()
    		               )
    		         ),
    		         FunctionFactory.INSTANCE.createConstant(attributeName),
    		         FunctionFactory.toActionContextFunction(
    		               TemplatedValue.transform(
    		                     FunctionFactory.createCoerceFunction(attributeType), 
    		                     attributeValue.toTemplate()
    		               )
    		         ),
    		         unit.toMillis(duration),
    		         conditionQuery==null?Predicates.alwaysTrue():FunctionFactory.toModelPredicate(this.conditionQuery.toTemplate(), variables)
    		      );
      }
      return action;
   }

   public  SetAttributeActionConfig();

}