Package net.bytebuddy.implementation
Interface MethodAccessorFactory
-
- All Known Subinterfaces:
Implementation.Context
,Implementation.Context.ExtractableView
- All Known Implementing Classes:
Implementation.Context.Default
,Implementation.Context.Disabled
,Implementation.Context.ExtractableView.AbstractBase
,MethodAccessorFactory.Illegal
public interface MethodAccessorFactory
A factory for creating method proxies for an auxiliary type. Such proxies are required to allow a type to call methods of a second type that are usually not accessible for the first type. This strategy is also adapted by the Java compiler that creates accessor methods for example to implement inner classes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
MethodAccessorFactory.AccessType
Indicates the type of access to an accessor method.static class
MethodAccessorFactory.Illegal
A method accessor factory that forbids any accessor registration.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description MethodDescription.InDefinedShape
registerAccessorFor(Implementation.SpecialMethodInvocation specialMethodInvocation, MethodAccessorFactory.AccessType accessType)
Registers an accessor method for aImplementation.SpecialMethodInvocation
which cannot itself be triggered invoked directly from outside a type.MethodDescription.InDefinedShape
registerGetterFor(FieldDescription fieldDescription, MethodAccessorFactory.AccessType accessType)
Registers a getter for the givenFieldDescription
which might itself not be accessible from outside the class.MethodDescription.InDefinedShape
registerSetterFor(FieldDescription fieldDescription, MethodAccessorFactory.AccessType accessType)
Registers a setter for the givenFieldDescription
which might itself not be accessible from outside the class.
-
-
-
Method Detail
-
registerAccessorFor
MethodDescription.InDefinedShape registerAccessorFor(Implementation.SpecialMethodInvocation specialMethodInvocation, MethodAccessorFactory.AccessType accessType)
Registers an accessor method for aImplementation.SpecialMethodInvocation
which cannot itself be triggered invoked directly from outside a type. The method is registered on the instrumented type with package-private visibility, similarly to a Java compiler's accessor methods.- Parameters:
specialMethodInvocation
- The special method invocation.accessType
- The required access type.- Returns:
- The accessor method for invoking the special method invocation.
-
registerGetterFor
MethodDescription.InDefinedShape registerGetterFor(FieldDescription fieldDescription, MethodAccessorFactory.AccessType accessType)
Registers a getter for the givenFieldDescription
which might itself not be accessible from outside the class. The returned getter method defines the field type as its return type, does not take any arguments and is of package-private visibility, similarly to the Java compiler's accessor methods. If the field isstatic
, this accessor method is alsostatic
.- Parameters:
fieldDescription
- The field which is to be accessed.accessType
- The required access type.- Returns:
- A getter method for the given field.
-
registerSetterFor
MethodDescription.InDefinedShape registerSetterFor(FieldDescription fieldDescription, MethodAccessorFactory.AccessType accessType)
Registers a setter for the givenFieldDescription
which might itself not be accessible from outside the class. The returned setter method defines the field type as its only argument type, returnsvoid
and is of package-private visibility, similarly to the Java compiler's accessor methods. If the field isstatic
, this accessor method is alsostatic
.- Parameters:
fieldDescription
- The field which is to be accessed.accessType
- The required access type.- Returns:
- A setter method for the given field.
-
-