本文整理了Java中java.lang.Class.getPackageName()
方法的一些代码示例,展示了Class.getPackageName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Class.getPackageName()
方法的具体详情如下:
包路径:java.lang.Class
类名称:Class
方法名:getPackageName
暂无
代码示例来源:origin: opengeospatial/geoapi
/**
* Specifies how the Java methods in the given interface should be mapped to Python methods or attributes.
* There is two main interfacing modes supported by default: if this method returns {@link Interfacing#GEOAPI},
* then the mapping between Java and Python uses the following rules:
*
* <ul>
* <li>For any Java method, the name of the corresponding Python attribute is given
* by the {@link org.opengis.annotation.UML} annotation associated to the method.
* If a method has no such annotation, then its name is used as a fallback.</li>
* <li>GeoAPI-specific property types are supported ({@link org.opengis.util.CodeList}
* and {@link InternationalString}) in addition of some Java standard types like
* {@link Enum} and {@link java.util.Collection}.</li>
* </ul>
*
* If this method returns {@link Interfacing#DEFAULT},
* then the Python-Java mapping is delegated to the underlying JPY library.
* If this method returns another value, then the behavior is defined by
* {@link Interfacing#toJava(PyObject, Class)}.
*
* @param type the Java type for which to determine the interfacing mode.
* @return a specification of how to interface Java methods to Python.
*/
protected Interfacing getInterfacing(final Class<?> type) {
return type.getPackageName().startsWith(Interfacing.GeoAPI.JAVA_PREFIX) ? Interfacing.GEOAPI : Interfacing.DEFAULT;
}
}
代码示例来源:origin: hibernate/hibernate-demos
@Override
protected Lookup computeValue(Class<?> type) {
if ( !getClass().getModule().canRead( type.getModule() ) ) {
getClass().getModule().addReads( type.getModule() );
}
packageOpener.openPackageIfNeeded(
type.getModule(), type.getPackageName(), FieldValueReaderImpl.class.getModule()
);
try {
return MethodHandles.privateLookupIn( type, MethodHandles.lookup() );
}
catch (IllegalAccessException e) {
throw new RuntimeException( e );
}
}
};
代码示例来源:origin: org.jooq/joor
if (className.startsWith(caller.getPackageName() + ".") &&
Character.isUpperCase(className.charAt(caller.getPackageName().length() + 1))) {
Lookup privateLookup = MethodHandles.privateLookupIn(caller, lookup);
result = fileManager.loadAndReturnMainClass(className,
代码示例来源:origin: elastic/apm-agent-java
@Test
void testMethodMatching() throws Exception {
assertMatches(MethodMatcher.of(getClass().getName() + "#*"), getClass().getDeclaredMethod("testMethodMatching"));
assertMatches(MethodMatcher.of(getClass().getName() + "#testMethodMatching"), getClass().getDeclaredMethod("testMethodMatching"));
assertMatches(MethodMatcher.of(getClass().getName() + "#testMethodMatching()"), getClass().getDeclaredMethod("testMethodMatching"));
assertMatches(MethodMatcher.of(getClass().getName() + "#testIntParameter"), getClass().getDeclaredMethod("testIntParameter", int.class));
assertMatches(MethodMatcher.of("private " + getClass().getName() + "#testIntParameter"), getClass().getDeclaredMethod("testIntParameter", int.class));
assertMatches(MethodMatcher.of("* " + getClass().getName() + "#testIntParameter"), getClass().getDeclaredMethod("testIntParameter", int.class));
assertMatches(MethodMatcher.of(getClass().getName() + "#testIntParameter(int)"), getClass().getDeclaredMethod("testIntParameter", int.class));
assertMatches(MethodMatcher.of(getClass().getName() + "#testStringParameter(java.lang.String)"), getClass().getDeclaredMethod("testStringParameter", String.class));
assertMatches(MethodMatcher.of("protected " + getClass().getName() + "#testStringParameter(java.lang.String)"), getClass().getDeclaredMethod("testStringParameter", String.class));
assertMatches(MethodMatcher.of("* " + getClass().getName() + "#testStringParameter(java.lang.String)"), getClass().getDeclaredMethod("testStringParameter", String.class));
assertMatches(MethodMatcher.of(getClass().getName() + "#testMultipleParameters(java.lang.String, int[], java.lang.Object[])"), getClass().getDeclaredMethod("testMultipleParameters", String.class, int[].class, Object[].class));
assertMatches(MethodMatcher.of(getClass().getName() + "#testMultipleParameters(*.String, int[], java.lang.Object[])"), getClass().getDeclaredMethod("testMultipleParameters", String.class, int[].class, Object[].class));
assertMatches(MethodMatcher.of(getClass().getName() + "#testMultipleParameters(*, *, *)"), getClass().getDeclaredMethod("testMultipleParameters", String.class, int[].class, Object[].class));
assertMatches(MethodMatcher.of(getClass().getPackageName() + "*#*"), getClass().getDeclaredMethod("testMethodMatching"));
assertMatches(MethodMatcher.of(getClass().getPackageName() + "*"), getClass().getDeclaredMethod("testMethodMatching"));
}
内容来源于网络,如有侵权,请联系作者删除!