Class MemberSelectorListMemberAccessPolicy.MemberSelector

    • Constructor Summary

      Constructors 
      Constructor Description
      MemberSelector​(java.lang.Class<?> upperBoundType, java.lang.reflect.Constructor<?> constructor)
      Use if you want to match constructors similar to the specified one, in types that are instanceof of the specified upper bound type.
      MemberSelector​(java.lang.Class<?> upperBoundType, java.lang.reflect.Field field)
      Use if you want to match fields similar to the specified one, in types that are instanceof of the specified upper bound type.
      MemberSelector​(java.lang.Class<?> upperBoundType, java.lang.reflect.Method method)
      Use if you want to match methods similar to the specified one, in types that are instanceof of the specified upper bound type.
    • Constructor Detail

      • MemberSelector

        public MemberSelector​(java.lang.Class<?> upperBoundType,
                              java.lang.reflect.Method method)
        Use if you want to match methods similar to the specified one, in types that are instanceof of the specified upper bound type. When methods are matched, only the name and the parameter types matter.
      • MemberSelector

        public MemberSelector​(java.lang.Class<?> upperBoundType,
                              java.lang.reflect.Constructor<?> constructor)
        Use if you want to match constructors similar to the specified one, in types that are instanceof of the specified upper bound type. When constructors are matched, only the parameter types matter.
      • MemberSelector

        public MemberSelector​(java.lang.Class<?> upperBoundType,
                              java.lang.reflect.Field field)
        Use if you want to match fields similar to the specified one, in types that are instanceof of the specified upper bound type. When fields are matched, only the name matters.
    • Method Detail

      • getUpperBoundType

        public java.lang.Class<?> getUpperBoundType()
        Not null.
      • getMethod

        public java.lang.reflect.Method getMethod()
        Maybe null; set if the selector matches methods similar to the returned one.
      • getConstructor

        public java.lang.reflect.Constructor<?> getConstructor()
        Maybe null; set if the selector matches constructors similar to the returned one.
      • getField

        public java.lang.reflect.Field getField()
        Maybe null; set if the selector matches fields similar to the returned one.
      • parse

        public static MemberSelectorListMemberAccessPolicy.MemberSelector parse​(java.lang.String memberSelectorString,
                                                                                java.lang.ClassLoader classLoader)
                                                                         throws java.lang.ClassNotFoundException,
                                                                                java.lang.NoSuchMethodException,
                                                                                java.lang.NoSuchFieldException
        Parses a member selector that was specified with a string.
        Parameters:
        classLoader - Used to resolve class names in the member selectors. Generally you want to pick a class that belongs to you application (not to a 3rd party library, like FreeMarker), and then call Class.getClassLoader() on that. Note that the resolution of the classes is not lazy, and so the ClassLoader won't be stored after this method returns.
        memberSelectorString - Describes the member (method, constructor, field) which you want to whitelist. Starts with the full qualified name of the member, like com.example.MyClass.myMember. Unless it's a field, the name is followed by comma separated list of the parameter types inside parentheses, like in com.example.MyClass.myMember(java.lang.String, boolean). The parameter type names must be also full qualified names, except primitive type names. Array types must be indicated with one or more []-s after the type name. Varargs arguments shouldn't be marked with ..., but with []. In the member name, like com.example.MyClass.myMember, the class refers to the so called "upper bound class". Regarding that and inheritance rules see the class level documentation.
        Throws:
        java.lang.ClassNotFoundException - If a type referred in the member selector can't be found.
        java.lang.NoSuchMethodException - If the method or constructor referred in the member selector can't be found.
        java.lang.NoSuchFieldException - If the field referred in the member selector can't be found.
      • parse

        public static java.util.List<MemberSelectorListMemberAccessPolicy.MemberSelector> parse​(java.util.Collection<java.lang.String> memberSelectors,
                                                                                                boolean ignoreMissingClassOrMember,
                                                                                                java.lang.ClassLoader classLoader)
                                                                                         throws java.lang.ClassNotFoundException,
                                                                                                java.lang.NoSuchMethodException,
                                                                                                java.lang.NoSuchFieldException
        Convenience method to parse all member selectors in the collection (see parse(String, ClassLoader)), while also filtering out blank and comment lines; see parse(String, ClassLoader), and isIgnoredLine(String).
        Parameters:
        ignoreMissingClassOrMember - If true, members selectors that throw exceptions because the referred type or member can't be found will be silently ignored. If true, same exceptions will be just thrown by this method.
        Throws:
        java.lang.ClassNotFoundException
        java.lang.NoSuchMethodException
        java.lang.NoSuchFieldException
      • isIgnoredLine

        public static boolean isIgnoredLine​(java.lang.String line)
        A line is ignored if it's blank or a comment. A line is be blank if it doesn't contain non-whitespace character. A line is a comment if it starts with #, or // (ignoring any amount of preceding whitespace).