Class BindingHelper


  • public class BindingHelper
    extends Object
    BindingHelper
    Author:
    shih-chang.chen@oracle.com
    • Constructor Detail

      • BindingHelper

        public BindingHelper()
    • Method Detail

      • mangleNameToVariableName

        @NotNull
        public static String mangleNameToVariableName​(@NotNull
                                                      String localName)
        Computes a Java identifier from a local name.

        This method faithfully implements the name mangling rule as specified in the JAXB spec.

        In JAXB, a collision with a Java reserved word (such as "return") never happens. Accordingly, this method may return an identifier that collides with reserved words.

        Use JJavaName.isJavaIdentifier(String) to check for such collision.

        Returns:
        Typically, this method returns "nameLikeThis".
      • mangleNameToClassName

        @NotNull
        public static String mangleNameToClassName​(@NotNull
                                                   String localName)
        Computes a Java class name from a local name.

        This method faithfully implements the name mangling rule as specified in the JAXB spec.

        Returns:
        Typically, this method returns "NameLikeThis".
      • mangleNameToPropertyName

        @NotNull
        public static String mangleNameToPropertyName​(@NotNull
                                                      String localName)
        Computes a Java class name from a local name.

        This method faithfully implements the name mangling rule as specified in the JAXB spec. This method works like mangleNameToClassName(String) except that it looks for "getClass" and returns something else.

        Returns:
        Typically, this method returns "NameLikeThis".
      • getBaseType

        @Nullable
        public static Type getBaseType​(@NotNull
                                       Type type,
                                       @NotNull
                                       Class baseType)
        Gets the parameterization of the given base type.

        For example, given the following

        
         interface Foo<T> extends List<List<T>> {}
         interface Bar extends Foo<String> {}
         
        This method works like this:
        
         getBaseClass( Bar, List ) = List<List<String>
         getBaseClass( Bar, Foo  ) = Foo<String>
         getBaseClass( Foo<? extends Number>, Collection ) = Collection<List<? extends Number>>
         getBaseClass( ArrayList<? extends BigInteger>, List ) = List<? extends BigInteger>
         
        Parameters:
        type - The type that derives from baseType
        baseType - The class whose parameterization we are interested in.
        Returns:
        The use of baseType in type. or null if the type is not assignable to the base type.
        Since:
        2.0 FCS
      • erasure

        public static <T> Class<T> erasure​(Type t)