public abstract class MemberSelectorListMemberAccessPolicy extends java.lang.Object implements MemberAccessPolicy
WhitelistMemberAccessPolicy
.
There are two ways you can add members to the member selector list:
Members are identified with the following data (with the example of
com.example.MyClass.myMethod(int, int)
):
com.example.MyClass
in the example)
myMethod
in the example), except for constructors where it's unused
int, int
in the example), except for fields where it's unused
If a method or field is matched in the upper bound type, it will be automatically matched in all subtypes of that.
It's called "upper bound" type, because the member will only be matched in classes that are instanceof
the upper bound class. That restriction stands even if the member was inherited from another type (class or
interface), and it wasn't even overridden in the upper bound type; the member won't be matched in the
type where it was inherited from, if that type is more generic than the upper bound type.
The above inheritance rule doesn't apply to constructors. That's consistent with the fact constructors aren't
inherited in Java (or pretty much any other language). So for example, if you add com.example.A.A()
to
the member selector list, and B extends A
, then com.example.B.B()
is still not matched by that list.
If you want it to be matched, you have to add com.example.B.B()
to list explicitly.
Note that the return type of methods aren't used in any way. If myMethod(int, int)
has multiple variants
with different return types (which is possible on the bytecode level) but the same parameter types, then all
variants of it is matched, or none is. Similarly, the type of fields isn't used either, only the name of the field
matters.
Modifier and Type | Class and Description |
---|---|
static class |
MemberSelectorListMemberAccessPolicy.MemberSelector
A condition that matches some type members.
|
Modifier and Type | Method and Description |
---|---|
ClassMemberAccessPolicy |
forClass(java.lang.Class<?> contextClass)
Returns the
ClassMemberAccessPolicy that encapsulates the member access policy for a given class. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isToStringAlwaysExposed
public final ClassMemberAccessPolicy forClass(java.lang.Class<?> contextClass)
MemberAccessPolicy
ClassMemberAccessPolicy
that encapsulates the member access policy for a given class.
ClassMemberAccessPolicy
implementations need not be thread-safe. Because class introspection results are
cached, and so this method is usually only called once for a given class, the ClassMemberAccessPolicy
instances shouldn't be cached by the implementation of this method.forClass
in interface MemberAccessPolicy
contextClass
- The exact class of object from which members will be get in the templates.