All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.jinjava.lib.exptest.IsMappingExpTest Maven / Gradle / Ivy

There is a newer version: 2.7.4
Show newest version
package com.hubspot.jinjava.lib.exptest;

import com.hubspot.jinjava.doc.annotations.JinjavaDoc;
import com.hubspot.jinjava.doc.annotations.JinjavaParam;
import com.hubspot.jinjava.doc.annotations.JinjavaSnippet;
import com.hubspot.jinjava.interpret.JinjavaInterpreter;
import java.util.Map;

@JinjavaDoc(
  value = "Return true if the given object is a dict",
  input = @JinjavaParam(value = "object", type = "object", required = true),
  snippets = {
    @JinjavaSnippet(
      code = "{% if variable is mapping %}\n" +
      "     \n" +
      "{% endif %}"
    ),
  }
)
public class IsMappingExpTest implements ExpTest {

  @Override
  public String getName() {
    return "mapping";
  }

  @Override
  public boolean evaluate(Object var, JinjavaInterpreter interpreter, Object... args) {
    return var != null && Map.class.isAssignableFrom(var.getClass());
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy