Tabnine Logo
Class.getPackage
Code IndexAdd Tabnine to your IDE (free)

How to use
getPackage
method
in
java.lang.Class

Best Java code snippets using java.lang.Class.getPackage (Showing top 20 results out of 31,941)

origin: spring-projects/spring-framework

/**
 * Return the full version string of the present Spring codebase,
 * or {@code null} if it cannot be determined.
 * @see Package#getImplementationVersion()
 */
@Nullable
public static String getVersion() {
  Package pkg = SpringVersion.class.getPackage();
  return (pkg != null ? pkg.getImplementationVersion() : null);
}
origin: prestodb/presto

/**
 * @since 2.7
 */
public static String getPackageName(Class<?> cls) {
  Package pkg = cls.getPackage();
  return (pkg == null) ? null : pkg.getName();
}
origin: ch.qos.logback/logback-classic

/**
 * {@inheritDoc}
 */
public void setLoggerContext(LoggerContext lc) {
  this.lc = lc;
  this.logger = lc.getLogger(getClass().getPackage().getName());
}
origin: org.mockito/mockito-core

private boolean isComingFromJDK(Class<?> type) {
  // Comes from the manifest entry :
  // Implementation-Title: Java Runtime Environment
  // This entry is not necessarily present in every jar of the JDK
  return type.getPackage() != null && "Java Runtime Environment".equalsIgnoreCase(type.getPackage().getImplementationTitle())
    || type.getName().startsWith("java.")
    || type.getName().startsWith("javax.");
}
origin: org.mockito/mockito-core

@Override
boolean isExported(Class<?> source) {
  if (source.getPackage() == null) {
    return true;
  }
  return (Boolean) invoke(isExportedUnqualified, invoke(getModule, source), source.getPackage().getName());
}
origin: org.mockito/mockito-core

@Override
boolean isExported(Class<?> source, Class<?> target) {
  if (source.getPackage() == null) {
    return true;
  }
  return (Boolean) invoke(isExported, invoke(getModule, source), source.getPackage().getName(), invoke(getModule, target));
}
origin: org.mockito/mockito-core

@Override
boolean isOpened(Class<?> source, Class<?> target) {
  if (source.getPackage() == null) {
    return true;
  }
  return (Boolean) invoke(isOpen, invoke(getModule, source), source.getPackage().getName(), invoke(getModule, target));
}
origin: prestodb/presto

@Test(groups = CLI, timeOut = TIMEOUT)
public void shouldDisplayVersion()
    throws IOException
{
  launchPrestoCli("--version");
  String version = firstNonNull(Presto.class.getPackage().getImplementationVersion(), "(version unknown)");
  assertThat(presto.readRemainingOutputLines()).containsExactly("Presto CLI " + version);
}
origin: google/guava

private List<Class<?>> loadClassesInPackage() throws IOException {
 List<Class<?>> classes = Lists.newArrayList();
 String packageName = getClass().getPackage().getName();
 for (ClassPath.ClassInfo classInfo :
   ClassPath.from(getClass().getClassLoader()).getTopLevelClasses(packageName)) {
  Class<?> cls;
  try {
   cls = classInfo.load();
  } catch (NoClassDefFoundError e) {
   // In case there were linking problems, this is probably not a class we care to test anyway.
   logger.log(Level.SEVERE, "Cannot load class " + classInfo + ", skipping...", e);
   continue;
  }
  if (!cls.isInterface()) {
   classes.add(cls);
  }
 }
 return classes;
}
origin: androidannotations/androidannotations

public File toGeneratedFile(Class<?> compiledClass) {
  File output = new File(OUTPUT_DIRECTORY, toPath(compiledClass.getPackage()) + "/" + compiledClass.getSimpleName() + getAndroidAnnotationsClassSuffix() + SOURCE_FILE_SUFFIX);
  return output;
}
origin: spring-projects/spring-framework

@Test
public void shouldNotScanTwice() {
  TestImport.scanned = false;
  AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
  context.scan(TestImport.class.getPackage().getName());
  context.refresh();
  context.getBean(TestConfiguration.class);
}
origin: bumptech/glide

@Test
public void testHasValidTag() {
 assertEquals(RequestManagerRetriever.class.getPackage().getName(),
   RequestManagerRetriever.FRAGMENT_TAG);
}
origin: spring-projects/spring-framework

/**
 * Prior to the fix for SPR-8761, this test threw because the nested MyComponent
 * annotation was being falsely considered as a 'lite' Configuration class candidate.
 */
@Test
public void repro() {
  AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
  ctx.scan(getClass().getPackage().getName());
  ctx.refresh();
  assertThat(ctx.containsBean("withNestedAnnotation"), is(true));
}
origin: spring-projects/spring-framework

@Test
public void testGetPackageName() {
  assertEquals("java.lang", ClassUtils.getPackageName(String.class));
  assertEquals(getClass().getPackage().getName(), ClassUtils.getPackageName(getClass()));
}
origin: spring-projects/spring-framework

/**
 * Prior to fixing SPR-10546 this might have succeeded depending on the ordering the
 * classes were picked up. If they are picked up in the same order as
 * {@link #enclosingConfigFirstParentDefinesBean()} then it would fail. This test is
 * mostly for illustration purposes, but doesn't hurt to continue using it.
 *
 * <p>We purposely use the {@link AEnclosingConfig} to make it alphabetically prior to the
 * {@link AEnclosingConfig.ChildConfig} which encourages this to occur with the
 * classpath scanning implementation being used by the author of this test.
 */
@Test
public void enclosingConfigFirstParentDefinesBeanWithScanning() {
  AnnotationConfigApplicationContext ctx= new AnnotationConfigApplicationContext();
  context = ctx;
  ctx.scan(AEnclosingConfig.class.getPackage().getName());
  ctx.refresh();
  assertThat(context.getBean("myBean",String.class), equalTo("myBean"));
}
origin: spring-projects/spring-framework

@Test
public void controlScan() {
  AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
  ctx.scan(example.scannable._package.class.getPackage().getName());
  ctx.refresh();
  assertThat("control scan for example.scannable package failed to register FooServiceImpl bean",
      ctx.containsBean("fooServiceImpl"), is(true));
}
origin: spring-projects/spring-framework

private ApplicationContext createContext(ScopedProxyMode scopedProxyMode) {
  GenericWebApplicationContext context = new GenericWebApplicationContext();
  ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
  scanner.setIncludeAnnotationConfig(false);
  scanner.setBeanNameGenerator((definition, registry) -> definition.getScope());
  scanner.setScopedProxyMode(scopedProxyMode);
  // Scan twice in order to find errors in the bean definition compatibility check.
  scanner.scan(getClass().getPackage().getName());
  scanner.scan(getClass().getPackage().getName());
  context.refresh();
  return context;
}
origin: spring-projects/spring-framework

@Test
public void naming() throws MalformedObjectNameException {
  JmxTestBean bean = new JmxTestBean();
  IdentityNamingStrategy strategy = new IdentityNamingStrategy();
  ObjectName objectName = strategy.getObjectName(bean, "null");
  assertEquals("Domain is incorrect", bean.getClass().getPackage().getName(),
      objectName.getDomain());
  assertEquals("Type property is incorrect", ClassUtils.getShortName(bean.getClass()),
      objectName.getKeyProperty(IdentityNamingStrategy.TYPE_KEY));
  assertEquals("HashCode property is incorrect", ObjectUtils.getIdentityHexString(bean),
      objectName.getKeyProperty(IdentityNamingStrategy.HASH_CODE_KEY));
}
origin: org.apache.commons/commons-lang3

@Test
public void testToFullyQualifiedNamePackageString() throws Exception {
  final String expected = "org.apache.commons.lang3.Test.properties";
  final String actual = ClassPathUtils.toFullyQualifiedName(ClassPathUtils.class.getPackage(), "Test.properties");
  assertEquals(expected, actual);
}
origin: org.apache.commons/commons-lang3

  @Test
  public void testToFullyQualifiedPathPackage() throws Exception {
    final String expected = "org/apache/commons/lang3/Test.properties";
    final String actual = ClassPathUtils.toFullyQualifiedPath(ClassPathUtils.class.getPackage(), "Test.properties");

    assertEquals(expected, actual);
  }
}
java.langClassgetPackage

Javadoc

Returns the Package of which the class represented by this Class is a member. Returns null if no Packageobject was created by the class loader of the class.

Popular methods of Class

  • getName
    Returns the name of the class represented by this Class. For a description of the format which is us
  • getSimpleName
  • getClassLoader
  • isAssignableFrom
    Determines if the class or interface represented by this Class object is either the same as, or is a
  • forName
    Returns the Class object associated with the class or interface with the given string name, using th
  • newInstance
    Returns a new instance of the class represented by this Class, created by invoking the default (that
  • getMethod
    Returns a Method object that reflects the specified public member method of the class or interface r
  • getResourceAsStream
  • getSuperclass
    Returns the Class representing the superclass of the entity (class, interface, primitive type or voi
  • getConstructor
  • cast
    Casts an object to the class or interface represented by this Class object.
  • isInstance
  • cast,
  • isInstance,
  • getCanonicalName,
  • getDeclaredField,
  • isArray,
  • getAnnotation,
  • getDeclaredFields,
  • getResource,
  • getDeclaredMethod,
  • getMethods

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • JFileChooser (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now