Skip to content

Commit

Permalink
Add @SuppressWarnings("UnusedReturnValue") to get rid of all warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
baloo42 committed Aug 5, 2024
1 parent 820ea3e commit 702ac34
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,21 @@ class CustomResourceClassLoader {

private ClassLoader cachedClassLoader;

@SuppressWarnings("UnusedReturnValue")
public CustomResourceClassLoader withParentClassLoader(ClassLoader parentClassLoader) {
this.parentClassLoader = parentClassLoader;
return this;
}

@SuppressWarnings("UnusedReturnValue")
public CustomResourceClassLoader withClasspathElement(String... classpathElements) {
if (classpathElements != null) {
withClasspathElements(Arrays.asList(classpathElements));
}
return this;
}

@SuppressWarnings("UnusedReturnValue")
public CustomResourceClassLoader withClasspathElements(Collection<String> classpathElements) {
if (classpathElements != null) {
classpathElements.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public CustomResourceCollector withParentClassLoader(ClassLoader classLoader) {
return this;
}

@SuppressWarnings("UnusedReturnValue")
public CustomResourceCollector withClasspathElement(String... classpathElement) {
this.customResourceClassLoader.withClasspathElement(classpathElement);
return this;
Expand All @@ -79,13 +80,15 @@ public CustomResourceCollector withClasspathElements(Collection<String> classpat
return this;
}

@SuppressWarnings("UnusedReturnValue")
public CustomResourceCollector withCustomResourceClass(String... className) {
if (className != null) {
withCustomResourceClasses(Arrays.asList(className));
}
return this;
}

@SuppressWarnings("UnusedReturnValue")
public CustomResourceCollector withCustomResourceClasses(Collection<String> classNames) {
if (classNames != null) {
classNames.stream()
Expand All @@ -95,11 +98,13 @@ public CustomResourceCollector withCustomResourceClasses(Collection<String> clas
return this;
}

@SuppressWarnings("UnusedReturnValue")
public CustomResourceCollector withIndex(IndexView... index) {
jandexCustomResourceClassScanner.withIndex(index);
return this;
}

@SuppressWarnings("UnusedReturnValue")
public CustomResourceCollector withIndices(Collection<IndexView> indices) {
jandexCustomResourceClassScanner.withIndices(indices);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,21 @@ public class JandexCustomResourceClassScanner {
*/
private boolean forceIndex = false;

@SuppressWarnings("UnusedReturnValue")
public JandexCustomResourceClassScanner withForceIndex(boolean forceIndex) {
this.forceIndex = forceIndex;
return this;
}

@SuppressWarnings("UnusedReturnValue")
public JandexCustomResourceClassScanner withIndex(IndexView... index) {
if (index != null) {
withIndices(Arrays.asList(index));
}
return this;
}

@SuppressWarnings("UnusedReturnValue")
public JandexCustomResourceClassScanner withIndices(Collection<IndexView> indices) {
if (indices != null) {
indices.stream()
Expand All @@ -79,13 +82,15 @@ public JandexCustomResourceClassScanner withIndices(Collection<IndexView> indice
return this;
}

@SuppressWarnings("UnusedReturnValue")
public JandexCustomResourceClassScanner withFileToScan(File... files) {
if (files != null) {
withFilesToScan(Arrays.asList(files));
}
return this;
}

@SuppressWarnings("UnusedReturnValue")
public JandexCustomResourceClassScanner withFilesToScan(Collection<File> files) {
if (files != null) {
files.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,23 @@ class JandexIndexer {
private long maxBytesReadFromJar = 100000000; // 100 MB
private long maxClassFileSize = 1000000; // 1 MB

@SuppressWarnings("UnusedReturnValue")
public JandexIndexer withMaxJarEntries(int maxJarEntries) {
if (maxJarEntries < 1)
throw new IllegalArgumentException("maxJarEntries must be greater than 0");
this.maxJarEntries = maxJarEntries;
return this;
}

@SuppressWarnings("UnusedReturnValue")
public JandexIndexer withMaxClassFileSize(int maxClassFileSize) {
if (maxClassFileSize < 10)
throw new IllegalArgumentException("maxClassFileSize must be greater than 10");
this.maxClassFileSize = maxClassFileSize;
return this;
}

@SuppressWarnings("UnusedReturnValue")
public JandexIndexer withMaxBytesReadFromJar(long maxBytesReadFromJar) {
if (maxBytesReadFromJar < 10)
throw new IllegalArgumentException("maxBytesReadFromJar must be greater than 10");
Expand Down Expand Up @@ -161,6 +164,7 @@ private long addToIndex(JarFile zip, JarEntry entry, Indexer indexer) {
}
}

@SuppressWarnings("UnusedReturnValue")
private long addToIndex(Path file, Indexer indexer) {
try (InputStream in = Files.newInputStream(file)) {
return addToIndex(in, indexer);
Expand Down

0 comments on commit 702ac34

Please sign in to comment.