congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
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

  • Creating JSON documents from java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • getSystemService (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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