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

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

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

Class.getPackageName介绍

暂无

代码示例

代码示例来源:origin: opengeospatial/geoapi

  1. /**
  2. * Specifies how the Java methods in the given interface should be mapped to Python methods or attributes.
  3. * There is two main interfacing modes supported by default: if this method returns {@link Interfacing#GEOAPI},
  4. * then the mapping between Java and Python uses the following rules:
  5. *
  6. * <ul>
  7. * <li>For any Java method, the name of the corresponding Python attribute is given
  8. * by the {@link org.opengis.annotation.UML} annotation associated to the method.
  9. * If a method has no such annotation, then its name is used as a fallback.</li>
  10. * <li>GeoAPI-specific property types are supported ({@link org.opengis.util.CodeList}
  11. * and {@link InternationalString}) in addition of some Java standard types like
  12. * {@link Enum} and {@link java.util.Collection}.</li>
  13. * </ul>
  14. *
  15. * If this method returns {@link Interfacing#DEFAULT},
  16. * then the Python-Java mapping is delegated to the underlying JPY library.
  17. * If this method returns another value, then the behavior is defined by
  18. * {@link Interfacing#toJava(PyObject, Class)}.
  19. *
  20. * @param type the Java type for which to determine the interfacing mode.
  21. * @return a specification of how to interface Java methods to Python.
  22. */
  23. protected Interfacing getInterfacing(final Class<?> type) {
  24. return type.getPackageName().startsWith(Interfacing.GeoAPI.JAVA_PREFIX) ? Interfacing.GEOAPI : Interfacing.DEFAULT;
  25. }
  26. }

代码示例来源:origin: hibernate/hibernate-demos

  1. @Override
  2. protected Lookup computeValue(Class<?> type) {
  3. if ( !getClass().getModule().canRead( type.getModule() ) ) {
  4. getClass().getModule().addReads( type.getModule() );
  5. }
  6. packageOpener.openPackageIfNeeded(
  7. type.getModule(), type.getPackageName(), FieldValueReaderImpl.class.getModule()
  8. );
  9. try {
  10. return MethodHandles.privateLookupIn( type, MethodHandles.lookup() );
  11. }
  12. catch (IllegalAccessException e) {
  13. throw new RuntimeException( e );
  14. }
  15. }
  16. };

代码示例来源:origin: org.jooq/joor

  1. if (className.startsWith(caller.getPackageName() + ".") &&
  2. Character.isUpperCase(className.charAt(caller.getPackageName().length() + 1))) {
  3. Lookup privateLookup = MethodHandles.privateLookupIn(caller, lookup);
  4. result = fileManager.loadAndReturnMainClass(className,

代码示例来源:origin: elastic/apm-agent-java

  1. @Test
  2. void testMethodMatching() throws Exception {
  3. assertMatches(MethodMatcher.of(getClass().getName() + "#*"), getClass().getDeclaredMethod("testMethodMatching"));
  4. assertMatches(MethodMatcher.of(getClass().getName() + "#testMethodMatching"), getClass().getDeclaredMethod("testMethodMatching"));
  5. assertMatches(MethodMatcher.of(getClass().getName() + "#testMethodMatching()"), getClass().getDeclaredMethod("testMethodMatching"));
  6. assertMatches(MethodMatcher.of(getClass().getName() + "#testIntParameter"), getClass().getDeclaredMethod("testIntParameter", int.class));
  7. assertMatches(MethodMatcher.of("private " + getClass().getName() + "#testIntParameter"), getClass().getDeclaredMethod("testIntParameter", int.class));
  8. assertMatches(MethodMatcher.of("* " + getClass().getName() + "#testIntParameter"), getClass().getDeclaredMethod("testIntParameter", int.class));
  9. assertMatches(MethodMatcher.of(getClass().getName() + "#testIntParameter(int)"), getClass().getDeclaredMethod("testIntParameter", int.class));
  10. assertMatches(MethodMatcher.of(getClass().getName() + "#testStringParameter(java.lang.String)"), getClass().getDeclaredMethod("testStringParameter", String.class));
  11. assertMatches(MethodMatcher.of("protected " + getClass().getName() + "#testStringParameter(java.lang.String)"), getClass().getDeclaredMethod("testStringParameter", String.class));
  12. assertMatches(MethodMatcher.of("* " + getClass().getName() + "#testStringParameter(java.lang.String)"), getClass().getDeclaredMethod("testStringParameter", String.class));
  13. assertMatches(MethodMatcher.of(getClass().getName() + "#testMultipleParameters(java.lang.String, int[], java.lang.Object[])"), getClass().getDeclaredMethod("testMultipleParameters", String.class, int[].class, Object[].class));
  14. assertMatches(MethodMatcher.of(getClass().getName() + "#testMultipleParameters(*.String, int[], java.lang.Object[])"), getClass().getDeclaredMethod("testMultipleParameters", String.class, int[].class, Object[].class));
  15. assertMatches(MethodMatcher.of(getClass().getName() + "#testMultipleParameters(*, *, *)"), getClass().getDeclaredMethod("testMultipleParameters", String.class, int[].class, Object[].class));
  16. assertMatches(MethodMatcher.of(getClass().getPackageName() + "*#*"), getClass().getDeclaredMethod("testMethodMatching"));
  17. assertMatches(MethodMatcher.of(getClass().getPackageName() + "*"), getClass().getDeclaredMethod("testMethodMatching"));
  18. }

相关文章

Class类方法