// Path: engine/src/main/java/com/impossibl/stencil/api/impl/AnnotatedCallableBase.java
// public abstract class AnnotatedCallableBase implements Callable {
//   
//   Method method;
// 
//   /**
//    * Examines a method named "doCall" for parameters annotated with the
//    * Named annotation.
//    * @see com.impossibl.stencil.api.Named
//    */
//   public String[] getParameterNames() {
//     return AnnotatedExtensions.getParameterNames(getMethod());
//   }
//   
//   /**
//    * Executes a method named "doCall" by mapping parameters by name to
//    * parameters annotated with the Named annotation
//    * @see com.impossibl.stencil.api.Named
//    */
//   public Object call(Map<String, ?> params) throws Throwable {
//     return AnnotatedExtensions.exec(getMethod(), getParameterNames(), params, this);
//   }
// 
//   /**
//    * Lookup a cached method named "doCall".
//    * 
//    * @return Cached "doCall" method
//    */
//   public Method getMethod() {
//     
//     if(method == null) {
//       method = AnnotatedExtensions.findMethod("doCall", getClass());
//     }
//     
//     return method;
//   }
// 
// }


import java.util.Map;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Predicate;
import com.google.common.collect.Maps;
import com.impossibl.stencil.api.Named;
import com.impossibl.stencil.api.impl.AnnotatedCallableBase;
package com.impossibl.stencil.ext.std;



@Named("attrs")
public class AttrsFunction extends AnnotatedCallableBase {
  
  public Object doCall(@Named("*") Map<String,Object> attrs, @Named("nulls") Boolean includeNulls) {

    includeNulls = includeNulls != null ? includeNulls : false;
    
    if(!includeNulls) {
      attrs = Maps.filterValues(attrs, new Predicate<Object>() {
  
        @Override
        public boolean apply(Object input) {
          return input != null;
        }
        
      });
    }
        
    attrs = Maps.transformValues(attrs, new Function<Object,Object>() {

      @Override
      public String apply(Object value) {
        return "\"" + value.toString() + "\"";
      }
      
// Path: engine/src/main/java/com/impossibl/stencil/api/impl/AnnotatedCallableBase.java
// public abstract class AnnotatedCallableBase implements Callable {
//   
//   Method method;
// 
//   /**
//    * Examines a method named "doCall" for parameters annotated with the
//    * Named annotation.
//    * @see com.impossibl.stencil.api.Named
//    */
//   public String[] getParameterNames() {
//     return AnnotatedExtensions.getParameterNames(getMethod());
//   }
//   
//   /**
//    * Executes a method named "doCall" by mapping parameters by name to
//    * parameters annotated with the Named annotation
//    * @see com.impossibl.stencil.api.Named
//    */
//   public Object call(Map<String, ?> params) throws Throwable {
//     return AnnotatedExtensions.exec(getMethod(), getParameterNames(), params, this);
//   }
// 
//   /**
//    * Lookup a cached method named "doCall".
//    * 
//    * @return Cached "doCall" method
//    */
//   public Method getMethod() {
//     
//     if(method == null) {
//       method = AnnotatedExtensions.findMethod("doCall", getClass());
//     }
//     
//     return method;
//   }
// 
// }


// Path: engine/src/main/java/com/impossibl/stencil/ext/std/AttrsFunction.java
import java.util.Map;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Predicate;
import com.google.common.collect.Maps;
import com.impossibl.stencil.api.Named;
import com.impossibl.stencil.api.impl.AnnotatedCallableBase;

package com.impossibl.stencil.ext.std;



@Named("attrs")
public class AttrsFunction extends AnnotatedCallableBase {
  
  public Object doCall(@Named("*") Map<String,Object> attrs, @Named("nulls") Boolean includeNulls) {

    includeNulls = includeNulls != null ? includeNulls : false;
    
    if(!includeNulls) {
      attrs = Maps.filterValues(attrs, new Predicate<Object>() {
  
        @Override
        public boolean apply(Object input) {
          return input != null;
        }
        
      });
    }
        
    attrs = Maps.transformValues(attrs, new Function<Object,Object>() {

      @Override
      public String apply(Object value) {
        return "\"" + value.toString() + "\"";
      }
      
    });