Skip to content

Commit

Permalink
add EmptyIndex and IndexView.empty()
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladicek committed Dec 13, 2023
1 parent 3c5ff01 commit 4340cae
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
93 changes: 93 additions & 0 deletions core/src/main/java/org/jboss/jandex/EmptyIndex.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package org.jboss.jandex;

import java.util.Collection;
import java.util.Collections;
import java.util.Set;

/**
* Immutable empty index; that is, an index that doesn't contain any class. All methods return either
* an empty collection, or {@code null}.
*
* @since 3.2.0
*/
public final class EmptyIndex implements IndexView {
static final EmptyIndex INSTANCE = new EmptyIndex();

private EmptyIndex() {
}

@Override
public Collection<ClassInfo> getKnownClasses() {
return Collections.emptySet();
}

@Override
public ClassInfo getClassByName(DotName className) {
return null;
}

@Override
public Collection<ClassInfo> getKnownDirectSubclasses(DotName className) {
return Collections.emptySet();
}

@Override
public Collection<ClassInfo> getAllKnownSubclasses(DotName className) {
return Collections.emptySet();
}

@Override
public Collection<ClassInfo> getKnownDirectSubinterfaces(DotName interfaceName) {
return Collections.emptySet();
}

@Override
public Collection<ClassInfo> getAllKnownSubinterfaces(DotName interfaceName) {
return Collections.emptySet();
}

@Override
public Collection<ClassInfo> getKnownDirectImplementors(DotName interfaceName) {
return Collections.emptySet();
}

@Override
public Collection<ClassInfo> getAllKnownImplementors(DotName interfaceName) {
return Collections.emptySet();
}

@Override
public Collection<AnnotationInstance> getAnnotations(DotName annotationName) {
return Collections.emptySet();
}

@Override
public Collection<AnnotationInstance> getAnnotationsWithRepeatable(DotName annotationName, IndexView index) {
return Collections.emptySet();
}

@Override
public Collection<ModuleInfo> getKnownModules() {
return Collections.emptySet();
}

@Override
public ModuleInfo getModuleByName(DotName moduleName) {
return null;
}

@Override
public Collection<ClassInfo> getKnownUsers(DotName className) {
return Collections.emptySet();
}

@Override
public Collection<ClassInfo> getClassesInPackage(DotName packageName) {
return Collections.emptySet();
}

@Override
public Set<DotName> getSubpackages(DotName packageName) {
return Collections.emptySet();
}
}
9 changes: 9 additions & 0 deletions core/src/main/java/org/jboss/jandex/IndexView.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
* @author Steve Ebersole
*/
public interface IndexView {
/**
* Returns an immutable empty index; that is, an index that doesn't contain any class.
* All methods return either an empty collection, or {@code null}.
*
* @since 3.2.0
*/
static IndexView empty() {
return EmptyIndex.INSTANCE;
}

/**
* Gets all known classes by this index (those which were scanned).
Expand Down

0 comments on commit 4340cae

Please sign in to comment.