本文整理匯總了Java中com.google.common.reflect.Reflection.getPackageName方法的典型用法代碼示例。如果您正苦於以下問題:Java Reflection.getPackageName方法的具體用法?Java Reflection.getPackageName怎麽用?Java Reflection.getPackageName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.reflect.Reflection
的用法示例。
在下文中一共展示了Reflection.getPackageName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getVisibleMethods
import com.google.common.reflect.Reflection; //導入方法依賴的package包/類
private ImmutableList<Method> getVisibleMethods(Class<?> cls) {
// Don't use cls.getPackage() because it does nasty things like reading
// a file.
String visiblePackage = Reflection.getPackageName(cls);
ImmutableList.Builder<Method> builder = ImmutableList.builder();
for (Class<?> type : TypeToken.of(cls).getTypes().rawTypes()) {
if (!Reflection.getPackageName(type).equals(visiblePackage)) {
break;
}
for (Method method : type.getDeclaredMethods()) {
if (!method.isSynthetic() && isVisible(method)) {
builder.add(method);
}
}
}
return builder.build();
}
示例2: getVisibleMethods
import com.google.common.reflect.Reflection; //導入方法依賴的package包/類
private ImmutableList<Method> getVisibleMethods(Class<?> cls) {
// Don't use cls.getPackage() because it does nasty things like reading
// a file.
String visiblePackage = Reflection.getPackageName(cls);
ImmutableList.Builder<Method> builder = ImmutableList.builder();
for (Class<?> type : TypeToken.of(cls).getTypes().classes().rawTypes()) {
if (!Reflection.getPackageName(type).equals(visiblePackage)) {
break;
}
for (Method method : type.getDeclaredMethods()) {
if (!method.isSynthetic() && isVisible(method)) {
builder.add(method);
}
}
}
return builder.build();
}
示例3: getPackageName
import com.google.common.reflect.Reflection; //導入方法依賴的package包/類
/**
* Returns the package name of the class, without attempting to load the class.
*
* <p>Behaves identically to {@link Package#getName()} but does not require the class (or
* package) to be loaded.
*/
public String getPackageName() {
return Reflection.getPackageName(className);
}