java.lang.Class.getPackageName()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中java.lang.Class.getPackageName()方法的一些代码示例,展示了Class.getPackageName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Class.getPackageName()方法的具体详情如下:
包路径:java.lang.Class
类名称:Class
方法名:getPackageName

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"));
}

相关文章

微信公众号

最新文章

更多

Class类方法