congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
JtwigFunction
Code IndexAdd Tabnine to your IDE (free)

How to use
JtwigFunction
in
com.lyncode.jtwig.functions.annotations

Best Java code snippets using com.lyncode.jtwig.functions.annotations.JtwigFunction (Showing top 20 results out of 315)

origin: com.lyncode/jtwig-functions

  @JtwigFunction(name = "last")
  public Object last (@Parameter Map input) {
    if (input.isEmpty()) return null;
    Iterator iterator = input.keySet().iterator();
    Object key = iterator.next();
    while (iterator.hasNext()) key = iterator.next();
    return input.get(key);
  }
}
origin: com.lyncode/jtwig-functions

@Override
public FunctionRepository include(Object instance) {
  for (Method method : instance.getClass().getDeclaredMethods()) {
    JtwigFunction annotation = method.getAnnotation(JtwigFunction.class);
    if (annotation != null) {
      this.add(annotation.name(), functionFrom(method).on(instance));
      this.aliases(annotation.name(), annotation.aliases());
    }
  }
  return this;
}
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "concat", aliases = { "concatenate" })
public String concatenate (@Parameter String... pieces) {
  StringBuilder builder = new StringBuilder();
  for (String piece : pieces) {
    if (piece != null)
      builder.append(piece);
  }
  return builder.toString();
}
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "sort")
public List sort (@Parameter List input) {
  Collections.sort(input);
  return input;
}

origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "abs")
public Double abs (@Parameter Double input) {
  return Math.abs(input);
}
@JtwigFunction(name = "abs")
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "length")
public int length (@Parameter Object input) {
  if (input instanceof String)
    return ((String) input).length();
  else
    return 1;
}
origin: com.lyncode/jtwig-functions

  @JtwigFunction(name = "toInt")
  public Integer toInt (@Parameter Object input) {
    if (input instanceof Number)
      return ((Number) input).intValue();
    return Integer.parseInt(input.toString());
  }
}
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "length")
public int length (@Parameter Iterable input) {
  Iterator iterator = input.iterator();
  int count = 0;
  while (iterator.hasNext()) {
    iterator.next();
    count++;
  }
  return count;
}
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "abs")
public Long abs (@Parameter Long input) {
  return Math.abs(input);
}
@JtwigFunction(name = "abs")
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "abs")
public Integer abs (@Parameter Integer input) {
  return Math.abs(input);
}
@JtwigFunction(name = "round")
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "iterable")
public boolean iterable(@Parameter Object input) {
  return input instanceof Iterable
      || input.getClass().isArray()
      || input instanceof Map;
}
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "url_encode")
public String urlEncode (@Parameter String input) throws UnsupportedEncodingException {
  return URLEncoder.encode(input, Charset.defaultCharset().displayName());
}
@JtwigFunction(name = "url_encode")
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "first")
public Object first (@Parameter Map input) {
  if (input.isEmpty()) return null;
  return input.get(input.keySet().iterator().next());
}
@JtwigFunction(name = "last")
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "abs")
public Float abs (@Parameter Float input) {
  return Math.abs(input);
}
@JtwigFunction(name = "abs")
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "first")
public Object first (@Parameter Object input) {
  if (input == null) return input;
  if (input.getClass().isArray()) {
    if (Array.getLength(input) == 0) return null;
    return Array.get(input, 0);
  } else return input;
}
@JtwigFunction(name = "last")
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "last")
public Object last (@Parameter Object input) {
  if (input == null) return input;
  if (input.getClass().isArray()) {
    int length = Array.getLength(input);
    if (length == 0) return null;
    return Array.get(input, length - 1);
  } else return input;
}
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "odd")
public boolean odd(@Parameter int number) {
  return number % 2 == 1;
}
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "lower")
public String lower (@Parameter String input) {
  return input.toLowerCase();
}
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "reverse")
public String reverse (@Parameter String input) {
  return new StringBuilder(input).reverse().toString();
}
origin: com.lyncode/jtwig-functions

@JtwigFunction(name = "last")
public Object last (@Parameter List input) {
  if (input.isEmpty()) return null;
  return input.get(input.size() - 1);
}
com.lyncode.jtwig.functions.annotationsJtwigFunction

Most used methods

  • <init>
  • aliases
  • name

Popular in Java

  • Parsing JSON documents to java classes using gson
  • scheduleAtFixedRate (Timer)
  • setContentView (Activity)
  • getSystemService (Context)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • ImageIO (javax.imageio)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now