Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public Set<MappingFileDescriptor> getLocatedMappingFiles() {
};
}

public static class MappingFileDescriptorImpl implements MappingFileDescriptor {
public static final class MappingFileDescriptorImpl
implements MappingFileDescriptor {
private final String name;
private final InputStreamAccess streamAccess;

Expand All @@ -102,5 +103,11 @@ public String getName() {
public InputStreamAccess getStreamAccess() {
return streamAccess;
}
@Override
public String toString() {
return "MappingFileDescriptorImpl["
+ "name=" + name + ", "
+ "streamAccess=" + streamAccess + ']';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ else if ( classDescriptor.getCategorization() == ClassDescriptor.Categorization.
unresolvedListedClassNames.remove( classDescriptor.getName() );
}

// IMPL NOTE : "explicitlyListedClassNames" can contain class or package names...
// IMPL NOTE: "explicitlyListedClassNames" can contain class or package names...
for ( PackageDescriptor packageDescriptor : scanResult.getLocatedPackages() ) {
managedResources.addAnnotatedPackageName( packageDescriptor.getName() );
unresolvedListedClassNames.remove( packageDescriptor.getName() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@
/**
* @author Steve Ebersole
*/
public class ClassDescriptorImpl implements ClassDescriptor, Serializable {
private final String name;
private final Categorization categorization;
private final InputStreamAccess streamAccess;

public ClassDescriptorImpl(String name, Categorization categorization, InputStreamAccess streamAccess) {
this.name = name;
this.categorization = categorization;
this.streamAccess = streamAccess;
public record ClassDescriptorImpl
(String name, Categorization categorization, InputStreamAccess streamAccess)
implements ClassDescriptor, Serializable {

@Override
public boolean equals(Object object) {
return this == object
|| object instanceof ClassDescriptorImpl that && name.equals( that.name );
}

@Override
public int hashCode() {
return name.hashCode();
}

@Override
public String getName() {
return name;
}

@Override
public Categorization getCategorization() {
return categorization;
}
Expand All @@ -36,22 +41,4 @@ public Categorization getCategorization() {
public InputStreamAccess getStreamAccess() {
return streamAccess;
}

@Override
public boolean equals(Object o) {
if ( this == o ) {
return true;
}
if ( o == null || getClass() != o.getClass() ) {
return false;
}

ClassDescriptorImpl that = (ClassDescriptorImpl) o;
return name.equals( that.name );
}

@Override
public int hashCode() {
return name.hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
/**
* @author Steve Ebersole
*/
public class MappingFileDescriptorImpl implements MappingFileDescriptor, Serializable {
public final class MappingFileDescriptorImpl
implements MappingFileDescriptor, Serializable {
private final String name;
private final InputStreamAccess streamAccess;

Expand All @@ -31,26 +32,10 @@ public InputStreamAccess getStreamAccess() {
return streamAccess;
}

// @Override
// public boolean equals(Object o) {
// if ( this == o ) {
// return true;
// }
// if ( o == null || getClass() != o.getClass() ) {
// return false;
// }
//
// MappingFileDescriptorImpl that = (MappingFileDescriptorImpl) o;
//
// return name.equals( that.name )
// && streamAccess.getStreamName().equals( that.streamAccess.getStreamName() );
//
// }
//
// @Override
// public int hashCode() {
// int result = name.hashCode();
// result = 31 * result + streamAccess.getStreamName().hashCode();
// return result;
// }
@Override
public String toString() {
return "MappingFileDescriptorImpl["
+ "name=" + name + ", "
+ "streamAccess=" + streamAccess + ']';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,29 @@
/**
* @author Steve Ebersole
*/
public class PackageDescriptorImpl implements PackageDescriptor, Serializable {
private final String name;
private final InputStreamAccess streamAccess;
public record PackageDescriptorImpl
(String name, InputStreamAccess streamAccess)
implements PackageDescriptor, Serializable {

public PackageDescriptorImpl(String name, InputStreamAccess streamAccess) {
this.name = name;
this.streamAccess = streamAccess;
}

@Override
public String getName() {
return name;
public boolean equals(Object object) {
return this == object
|| object instanceof PackageDescriptorImpl that && name.equals( that.name );
}

@Override
public InputStreamAccess getStreamAccess() {
return streamAccess;
public int hashCode() {
return name.hashCode();
}

@Override
public boolean equals(Object o) {
if ( this == o ) {
return true;
}
if ( o == null || getClass() != o.getClass() ) {
return false;
}

PackageDescriptorImpl that = (PackageDescriptorImpl) o;
return name.equals( that.name );
public String getName() {
return name;
}

@Override
public int hashCode() {
return name.hashCode();
public InputStreamAccess getStreamAccess() {
return streamAccess;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,22 @@ public void handleClass(ClassDescriptor classDescriptor, boolean rootUrl) {
discoveredClasses.add( classDescriptor );
}

@SuppressWarnings("SimplifiableIfStatement")
protected boolean isListedOrDetectable(String name, boolean rootUrl) {
// IMPL NOTE : protect the calls to getExplicitlyListedClassNames unless needed,
// IMPL NOTE: protect the calls to getExplicitlyListedClassNames unless needed,
// since it can take time with lots of listed classes.
if ( rootUrl ) {
// The entry comes from the root url. Allow it if either:
// 1) we are allowed to discover classes/packages in the root url
// 2) the entry was explicitly listed
return options.canDetectUnlistedClassesInRoot()
|| environment.getExplicitlyListedClassNames().contains( name );
|| environment.getExplicitlyListedClassNames().contains( name );
}
else {
// The entry comes from a non-root url. Allow it if either:
// 1) we are allowed to discover classes/packages in non-root urls
// 2) the entry was explicitly listed
return options.canDetectUnlistedClassesInNonRoot()
|| environment.getExplicitlyListedClassNames().contains( name );
|| environment.getExplicitlyListedClassNames().contains( name );
}
}

Expand All @@ -88,7 +87,6 @@ public void handleMappingFile(MappingFileDescriptor mappingFileDescriptor, boole
}
}

@SuppressWarnings("SimplifiableIfStatement")
private boolean acceptAsMappingFile(MappingFileDescriptor mappingFileDescriptor, boolean rootUrl) {
if ( mappingFileDescriptor.getName().endsWith( "hbm.xml" ) ) {
return options.canDetectHibernateMappingFiles();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,13 @@


/**
* @author Steve Ebersole
*/
public class ScanResultImpl implements ScanResult, Serializable {
private final Set<PackageDescriptor> packageDescriptorSet;
private final Set<ClassDescriptor> classDescriptorSet;
private final Set<MappingFileDescriptor> mappingFileSet;

public ScanResultImpl(
Set<PackageDescriptor> packageDescriptorSet,
Set<ClassDescriptor> classDescriptorSet,
Set<MappingFileDescriptor> mappingFileSet) {
this.packageDescriptorSet = packageDescriptorSet;
this.classDescriptorSet = classDescriptorSet;
this.mappingFileSet = mappingFileSet;
}
* @author Steve Ebersole
*/
public record ScanResultImpl(
Set<PackageDescriptor> packageDescriptorSet,
Set<ClassDescriptor> classDescriptorSet,
Set<MappingFileDescriptor> mappingFileSet
) implements ScanResult, Serializable {

@Override
public Set<PackageDescriptor> getLocatedPackages() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
public class StandardScannerFactory implements ScannerFactory {
@Override
public Scanner getScanner(ArchiveDescriptorFactory archiveDescriptorFactory) {
if ( archiveDescriptorFactory == null ) {
return new StandardScanner();
}
return new StandardScanner( archiveDescriptorFactory );
return archiveDescriptorFactory == null
? new StandardScanner()
: new StandardScanner( archiveDescriptorFactory );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
public abstract class AbstractScannerImpl implements Scanner {
private final ArchiveDescriptorFactory archiveDescriptorFactory;
private final Map<URL, ArchiveDescriptorInfo> archiveDescriptorCache = new HashMap<>();
private final Map<String, ArchiveDescriptorInfo> archiveDescriptorCache = new HashMap<>();

protected AbstractScannerImpl(ArchiveDescriptorFactory archiveDescriptorFactory) {
this.archiveDescriptorFactory = archiveDescriptorFactory;
Expand Down Expand Up @@ -62,13 +62,13 @@ private ArchiveDescriptor buildArchiveDescriptor(
ScanEnvironment environment,
boolean isRootUrl) {
final ArchiveDescriptor descriptor;
final ArchiveDescriptorInfo descriptorInfo = archiveDescriptorCache.get( url );
final ArchiveDescriptorInfo descriptorInfo = archiveDescriptorCache.get( url.toExternalForm() );
if ( descriptorInfo == null ) {
if ( !isRootUrl && archiveDescriptorFactory instanceof JarFileEntryUrlAdjuster jarFileEntryUrlAdjuster ) {
url = jarFileEntryUrlAdjuster.adjustJarFileEntryUrl( url, environment.getRootUrl() );
}
descriptor = archiveDescriptorFactory.buildArchiveDescriptor( url );
archiveDescriptorCache.put( url, new ArchiveDescriptorInfo( descriptor, isRootUrl ) );
archiveDescriptorCache.put( url.toExternalForm(), new ArchiveDescriptorInfo( descriptor, isRootUrl ) );
}
else {
validateReuse( descriptorInfo, isRootUrl );
Expand Down Expand Up @@ -135,9 +135,9 @@ public ArchiveEntryHandler obtainArchiveEntryHandler(ArchiveEntry entry) {
return packageEntryHandler;
}
else if ( nameWithinArchive.endsWith( "module-info.class" ) ) {
//There's two reasons to skip this: the most important one is that Jandex
//is unable to analyze them, so we need to dodge it.
//Secondarily, we have no use for these so let's save the effort.
// There are two reasons to skip this: the most important one is
// that Jandex is unable to analyze them, so we need to dodge it.
// Secondly, we have no use for these, so let's save the effort.
return NoopEntryHandler.NOOP_INSTANCE;
}
else if ( nameWithinArchive.endsWith( ".class" ) ) {
Expand Down