Skip to content

Commit

Permalink
Apply code simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
ottlinger committed Dec 16, 2024
1 parent 78f1d02 commit e3bdaad
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 29 deletions.
5 changes: 2 additions & 3 deletions src/main/java/org/apache/creadur/tentacles/Deauthorize.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,10 @@ private static void deauthorize(final File dir, final IOSystem io)
in = new DelimitedTokenReplacementInputStream(in, startComment,
endComment, new StringTokenHandler() {
@Override
public String handleToken(final String commentBlock)
throws IOException {
public String handleToken(final String commentBlock) {

// Yank if empty
if (commentBlock.replaceAll("[\\s*]", "").length() == 0) {
if (commentBlock.replaceAll("[\\s*]", "").isEmpty()) {
return eol;
}

Expand Down
11 changes: 6 additions & 5 deletions src/main/java/org/apache/creadur/tentacles/IOSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.logging.log4j.*;
import java.io.*;
import java.net.URL;
import java.nio.file.Files;
import java.util.zip.ZipInputStream;

public class IOSystem {
Expand All @@ -27,13 +28,13 @@ public class IOSystem {
public String slurp(final File file) throws IOException {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(file, out);
return new String(out.toByteArray());
return out.toString();
}

public String slurp(final URL url) throws IOException {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(url.openStream(), out);
return new String(out.toByteArray());
return out.toString();
}

public void writeString(final File file, final String string) throws IOException {
Expand Down Expand Up @@ -87,7 +88,7 @@ public ZipInputStream unzip(final File file) throws IOException {
return new ZipInputStream(read);
}

public void close(final Closeable closeable) throws IOException {
public void close(final Closeable closeable) {
if (closeable == null) {
return;
}
Expand All @@ -106,12 +107,12 @@ public void close(final Closeable closeable) throws IOException {
}

public OutputStream write(final File destination) throws FileNotFoundException {
final OutputStream out = new FileOutputStream(destination);
final OutputStream out = Files.newOutputStream(destination.toPath());
return new BufferedOutputStream(out, 32768);
}

public InputStream read(final File source) throws FileNotFoundException {
final InputStream in = new FileInputStream(source);
final InputStream in = Files.newInputStream(source.toPath());
return new BufferedInputStream(in, 32768);
}

Expand Down
6 changes: 1 addition & 5 deletions src/main/java/org/apache/creadur/tentacles/License.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ public boolean equals(final Object o) {

final License license = (License) o;

if (!this.key.equals(license.key)) {
return false;
}

return true;
return this.key.equals(license.key);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/creadur/tentacles/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ private Set<File> mirrorRepositoryFrom(final Configuration configuration)
return files;
}

private void unpack(final File archive) throws IOException {
private void unpack(final File archive) {
log.info("Unpack {}", archive);

try {
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/org/apache/creadur/tentacles/Notice.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ public boolean equals(final Object o) {

final Notice notice = (Notice) o;

if (!this.key.equals(notice.key)) {
return false;
}

return true;
return this.key.equals(notice.key);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

final class AndFilter implements FileFilter {

List<FileFilter> filters = new ArrayList<>();
final List<FileFilter> filters = new ArrayList<>();

AndFilter(final FileFilter... filters) {
for (final FileFilter filter : filters) {
this.filters.add(filter);
}
this.filters.addAll(Arrays.asList(filters));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class ListOfFilesFilter implements FileFilter {

private List<String> listOfFiles;
private final List<String> listOfFiles;

ListOfFilesFilter(String... files) {
listOfFiles = Arrays.asList(files);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/legal/archive-licenses.vm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
####################################################################################
//-->
<html>
<html lang="en">
<head>
<link href="style.css" type="text/css" rel="stylesheet" />
</head>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/legal/archive-notices.vm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
####################################################################################
//-->
<html>
<html lang="en">
<head>
<link href="style.css" type="text/css" rel="stylesheet" />
</head>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/legal/archives.vm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
####################################################################################
//-->
<html>
<html lang="en">
<head>
<link href="style.css" type="text/css" rel="stylesheet"/>
</head>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/legal/licenses.vm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
####################################################################################
//-->
<html>
<html lang="en">
<head>
<link href="style.css" type="text/css" rel="stylesheet" />
</head>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/legal/notices.vm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
####################################################################################
//-->
<html>
<html lang="en">
<head>
<link href="style.css" type="text/css" rel="stylesheet" />
</head>
Expand Down

0 comments on commit e3bdaad

Please sign in to comment.