public final class MethodUtil extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
isMethodAccessibleFromClass(Class> clazz, Method method, boolean privateMethodAccapted)
Check if method is accesible from the provided
Class parameter based on the chapter 112.9.4 Locating Component Methods of OSGi compendium specification:
|
static Method |
locateMethodByPreference(Class> clazz, boolean privateMethodAccepted, MethodDescriptor... methodDefinitions)
Locates the first method that exists from the definition array.
|
public static boolean isMethodAccessibleFromClass(Class> clazz, Method method, boolean privateMethodAccapted)
Class
parameter based on the chapter 112.9.4 Locating Component Methods of OSGi compendium specification:
"If the method has the public or protected access modifier, then access is permitted. Otherwise, if the method has the private access modifier, then access is permitted only if the method is declared in the component implementation class. Otherwise, if the method has default access, also known as package private access, then access is permitted only if the method is declared in the component implementation class or if the method is declared in a superclass and all classes in the hierarchy from the component implementation class to the superclass, inclusive, are in the same package and loaded by the same class loader."
clazz
- The type that must have access to the method.method
- The method that should be accessible from the class.privateMethodAccapted
- Whether a method that is declared in clazz, should be accessible even if it is private. Based on the content of the specification, these methods should be marked as acecssible as well. However, private methods cannot be called via reflection by default, so there is an option to exclude private methods.public static Method locateMethodByPreference(Class> clazz, boolean privateMethodAccepted, MethodDescriptor... methodDefinitions)
MethodDescriptor.locate(Class, boolean)
.
clazz
- The class where the search is started. The class and its super classes are checked.privateMethodAccepted
- Whether to accept private method if it is locaed in the class that is specified with the clazz parameter or not.methodDefinitions
- The method definitions that are searched in preference order.null
if no matching method was found.Copyright © 2015 Everit Kft.. All rights reserved.