Class JExprs


  • public final class JExprs
    extends java.lang.Object
    The factory for generating simple expressions.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static java.lang.ThreadLocal<java.util.LinkedHashMap<java.lang.String,​JAssignableExpr>> cache  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private JExprs()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static JAssignableExpr $v​(java.lang.String name)
      Return a name expression.
      static JAssignableExpr $v​(JParamDeclaration paramDeclaration)
      Return a name expression from an annotation processor parameter declaration.
      static JAssignableExpr $v​(JVarDeclaration varDeclaration)
      Return a name expression from an annotation processor variable declaration.
      static JArrayExpr array()
      Return a new array expression.
      static JArrayExpr array​(int... members)
      Return a new array expression.
      static JArrayExpr array​(long... members)
      Return a new array expression.
      static JArrayExpr array​(java.lang.String... members)
      Return a new array expression.
      static JArrayExpr array​(JExpr... members)
      Return a new array expression.
      static JExpr binary​(int val)
      Generate an int value in binary base.
      static JExpr binary​(long val)
      Generate a long value in binary base.
      static JCall call​(java.lang.String name)
      Generate a method call expression to the given method name.
      static JCall call​(javax.lang.model.element.ExecutableElement element)
      Generate a method call expression to the given element.
      static JCall callStatic​(java.lang.Class<?> type, java.lang.String name)
      Generate a method call expression to a method on the given static type.
      static JCall callStatic​(java.lang.String type, java.lang.String name)
      Generate a method call expression to a method on the given static type.
      static JCall callStatic​(JType type, java.lang.String name)
      Generate a method call expression to a method on the given static type.
      static JExpr ch​(int val)
      Generate a char value constant.
      static JExpr decimal​(double val)
      Generate a double value in decimal base.
      static JExpr decimal​(float val)
      Generate a float value in decimal base.
      static JExpr decimal​(int val)
      Generate an int value in decimal base.
      static JExpr decimal​(long val)
      Generate a long value in decimal base.
      static JExpr hex​(double val)
      Generate a double value in hexadecimal base.
      static JExpr hex​(float val)
      Generate a float value in hexadecimal base.
      static JExpr hex​(int val)
      Generate an int value in hexadecimal base.
      static JExpr hex​(long val)
      Generate a long value in hexadecimal base.
      static JLambda lambda()
      Return a lambda expression.
      static JAssignableExpr name​(java.lang.String name)
      Return a name expression.
      static JAssignableExpr name​(JParamDeclaration paramDeclaration)
      Return a name expression from an annotation processor parameter declaration.
      static JAssignableExpr name​(JVarDeclaration varDeclaration)
      Return a name expression from an annotation processor variable declaration.
      static JExpr str​(java.lang.String string)
      Generate a string constant value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • cache

        static final java.lang.ThreadLocal<java.util.LinkedHashMap<java.lang.String,​JAssignableExpr>> cache
    • Constructor Detail

      • JExprs

        private JExprs()
    • Method Detail

      • decimal

        public static JExpr decimal​(int val)
        Generate an int value in decimal base.
        Parameters:
        val - the value
        Returns:
        the value expression
      • decimal

        public static JExpr decimal​(long val)
        Generate a long value in decimal base.
        Parameters:
        val - the value
        Returns:
        the value expression
      • decimal

        public static JExpr decimal​(float val)
        Generate a float value in decimal base.
        Parameters:
        val - the value
        Returns:
        the value expression
      • decimal

        public static JExpr decimal​(double val)
        Generate a double value in decimal base.
        Parameters:
        val - the value
        Returns:
        the value expression
      • hex

        public static JExpr hex​(int val)
        Generate an int value in hexadecimal base.
        Parameters:
        val - the value
        Returns:
        the value expression
      • hex

        public static JExpr hex​(long val)
        Generate a long value in hexadecimal base.
        Parameters:
        val - the value
        Returns:
        the value expression
      • hex

        public static JExpr hex​(float val)
        Generate a float value in hexadecimal base.
        Parameters:
        val - the value
        Returns:
        the value expression
      • hex

        public static JExpr hex​(double val)
        Generate a double value in hexadecimal base.
        Parameters:
        val - the value
        Returns:
        the value expression
      • binary

        public static JExpr binary​(int val)
        Generate an int value in binary base.
        Parameters:
        val - the value
        Returns:
        the value expression
      • binary

        public static JExpr binary​(long val)
        Generate a long value in binary base.
        Parameters:
        val - the value
        Returns:
        the value expression
      • str

        public static JExpr str​(java.lang.String string)
        Generate a string constant value.
        Parameters:
        string - the string
        Returns:
        the string expression
      • ch

        public static JExpr ch​(int val)
        Generate a char value constant.
        Parameters:
        val - the value
        Returns:
        the value expression
      • call

        public static JCall call​(javax.lang.model.element.ExecutableElement element)
        Generate a method call expression to the given element.
        Parameters:
        element - the method to call
        Returns:
        the method call
      • call

        public static JCall call​(java.lang.String name)
        Generate a method call expression to the given method name.
        Parameters:
        name - the name of the method to call
        Returns:
        the method call
      • callStatic

        public static JCall callStatic​(java.lang.String type,
                                       java.lang.String name)
        Generate a method call expression to a method on the given static type.
        Parameters:
        type - the type to call against
        name - the name of the method to call
        Returns:
        the method call
      • callStatic

        public static JCall callStatic​(JType type,
                                       java.lang.String name)
        Generate a method call expression to a method on the given static type.
        Parameters:
        type - the type to call against
        name - the name of the method to call
        Returns:
        the method call
      • callStatic

        public static JCall callStatic​(java.lang.Class<?> type,
                                       java.lang.String name)
        Generate a method call expression to a method on the given static type.
        Parameters:
        type - the type to call against
        name - the name of the method to call
        Returns:
        the method call
      • $v

        public static JAssignableExpr $v​(java.lang.String name)
        Return a name expression. This method is a shortcut for name(String).
        Parameters:
        name - the name
        Returns:
        the expression
      • $v

        public static JAssignableExpr $v​(JParamDeclaration paramDeclaration)
        Return a name expression from an annotation processor parameter declaration.
        Parameters:
        paramDeclaration - the method parameter
        Returns:
        the expression
      • $v

        public static JAssignableExpr $v​(JVarDeclaration varDeclaration)
        Return a name expression from an annotation processor variable declaration.
        Parameters:
        varDeclaration - the variable declaration
        Returns:
        the expression
      • name

        public static JAssignableExpr name​(java.lang.String name)
        Return a name expression.
        Parameters:
        name - the name
        Returns:
        the expression
      • name

        public static JAssignableExpr name​(JParamDeclaration paramDeclaration)
        Return a name expression from an annotation processor parameter declaration.
        Parameters:
        paramDeclaration - the method parameter
        Returns:
        the expression
      • name

        public static JAssignableExpr name​(JVarDeclaration varDeclaration)
        Return a name expression from an annotation processor variable declaration.
        Parameters:
        varDeclaration - the variable declaration
        Returns:
        the expression
      • array

        public static JArrayExpr array()
        Return a new array expression. The array is initially empty.
        Returns:
        an array expression
      • array

        public static JArrayExpr array​(JExpr... members)
        Return a new array expression. The array is initially filled with the given members.
        Parameters:
        members - the initial members of the array
        Returns:
        an array expression
      • array

        public static JArrayExpr array​(java.lang.String... members)
        Return a new array expression. The array is initially filled with the given strings.
        Parameters:
        members - the initial members of the array
        Returns:
        an array expression
      • array

        public static JArrayExpr array​(int... members)
        Return a new array expression. The array is initially filled with the given integers.
        Parameters:
        members - the initial members of the array
        Returns:
        an array expression
      • array

        public static JArrayExpr array​(long... members)
        Return a new array expression. The array is initially filled with the given integers.
        Parameters:
        members - the initial members of the array
        Returns:
        an array expression
      • lambda

        public static JLambda lambda()
        Return a lambda expression. The expression is initially empty.
        Returns:
        the lambda expression