Class TypeUtils


  • public class TypeUtils
    extends Object
    Utilities for parsing Java type descriptors and type signatures.
    Author:
    lukehutch
    • Field Detail

      • MODIFIER_SYNTHETIC

        public static final int MODIFIER_SYNTHETIC
        The modifier bit for synthetic parameters.
        See Also:
        Constant Field Values
      • MODIFIER_MANDATED

        public static final int MODIFIER_MANDATED
        The modifier bit for mandated parameters.
        See Also:
        Constant Field Values
    • Constructor Detail

      • TypeUtils

        public TypeUtils()
    • Method Detail

      • modifiersToString

        public static String modifiersToString​(int modifiers,
                                               boolean isMethod)
        Convert modifiers into a string representation, e.g. "public static final".
        Parameters:
        modifiers - The field, method or class modifiers.
        isMethod - True if this is a method, false if this is a field or class.
        Returns:
        The modifiers, as a string.
      • modifiersToString

        public static void modifiersToString​(int modifiers,
                                             boolean isMethod,
                                             StringBuilder buf)
        Convert modifiers into a string representation, e.g. "public static final".
        Parameters:
        modifiers - The field or method modifiers.
        isMethod - True if this is a method, false if this is a field or class.
        buf - The buffer to write the result into.
      • getIdentifierToken

        public static boolean getIdentifierToken​(Parser parser,
                                                 char separator,
                                                 char separatorReplace)
                                          throws Parser.ParseException
        Parse a Java identifier with the given separator ('.' or '/'). Potentially replaces the separator with a different character. Appends the identifier to the token buffer in the parser.
        Parameters:
        parser - The parser.
        separator - The separator character.
        separatorReplace - The character to replace the separator with.
        Returns:
        true if at least one identifier character was parsed.
        Throws:
        Parser.ParseException - If the parser ran out of input.
      • getIdentifierToken

        public static boolean getIdentifierToken​(Parser parser)
                                          throws Parser.ParseException
        Parse a Java identifier part (between separators and other non-alphanumeric characters). Appends the identifier to the token buffer in the parser.
        Parameters:
        parser - The parser.
        Returns:
        true if at least one identifier character was parsed.
        Throws:
        Parser.ParseException - If the parser ran out of input.