Class XLanguageUtils


  • public class XLanguageUtils
    extends Object
    Utility class for providing default languages
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • getAvailableDefaultLanguages

        public static Map<String,​String> getAvailableDefaultLanguages​(Locale displayLocale)
        Returns a map of language display names and their IETF BCP 47 language tag
        Parameters:
        displayLocale - Locale to be used for displaying the languages
        Returns:
        Map of language display names and their well-formed IETF BCP 47 language tag
      • isMethodImplementedBy

        public static boolean isMethodImplementedBy​(Class<?> target,
                                                    Object instance,
                                                    String methodName,
                                                    Class<?>... params)
        Checks whether the given method is implemented by the given target class. Returns false when implemented by a subclass. For example:
             interface A {
                 default void foo() {}
                 default void bar() {}
             }
             class B implements A {
               public void foo() {}
             }
        
             // false, because foo is implemented by B
             isMethodImplementedBy(A.class, new B(), "foo")
        
             // true, because B inherits the implementation of bar from A
             isMethodImplementedBy(A.class, new B(), "bar")
         
        Parameters:
        target - The target class.
        instance - The instance to check.
        methodName - The name of the method.
        params - The parameter types of the method.
        Returns:
        true when the method is implemented by the target class.
      • parseIntOrNull

        public static Integer parseIntOrNull​(String value)
        Parses the value as an integer, if possible, or returns null if it cannot be parsed.
        Parameters:
        value - Value to parse.
        Returns:
        The integer represented by the string, or null when the string does not represent a valid integer.
      • parseLongOrNull

        public static Long parseLongOrNull​(String value)
        Parses the value as a long, if possible, or returns null if it cannot be parsed.
        Parameters:
        value - Value to parse.
        Returns:
        The long represented by the string, or null when the string does not represent a valid long.