Skip to content

Commit

Permalink
checkstyle cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudenw committed Apr 29, 2024
1 parent 70b313d commit 5414610
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
34 changes: 16 additions & 18 deletions apache-rat-core/src/main/java/org/apache/rat/Defaults.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
import java.util.SortedSet;
import java.util.TreeSet;

import org.apache.commons.io.IOCase;
import org.apache.commons.io.filefilter.FalseFileFilter;
import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.commons.io.function.IOSupplier;
import org.apache.rat.configuration.Format;
import org.apache.rat.configuration.LicenseReader;
Expand All @@ -50,7 +48,7 @@
* Properties in this class may be overridden or added to by configuration options in the various UIs.
* See the specific UI for details.
*/
public class Defaults {
public final class Defaults {

/**
* The default configuration file from the package.
Expand Down Expand Up @@ -84,7 +82,7 @@ public static void init() {
/**
* Builder constructs instances.
*/
private Defaults(Log log, Set<URL> urls) {
private Defaults(final Log log, final Set<URL> urls) {
this.setFactory = Defaults.readConfigFiles(log, urls);
}

Expand All @@ -100,7 +98,7 @@ public static Builder builder() {
* Reads the configuration files.
* @param urls the URLs to read.
*/
private static LicenseSetFactory readConfigFiles(Log log, Collection<URL> urls) {
private static LicenseSetFactory readConfigFiles(final Log log, final Collection<URL> urls) {

SortedSet<ILicense> licenses = LicenseSetFactory.emptyLicenseSet();

Expand Down Expand Up @@ -146,16 +144,16 @@ public static IOSupplier<InputStream> getUnapprovedLicensesStyleSheet() {
* @param filter define which type of licenses to return.
* @return sorted set of licenses.
*/
public SortedSet<ILicense> getLicenses(LicenseFilter filter) {
public SortedSet<ILicense> getLicenses(final LicenseFilter filter) {
return setFactory.getLicenses(filter);
}

/**
* Gets the sorted set of approved licenses for a given filter condition.
* @param filter define which type of licenses to return.
* @return sorted set of license families.
*/
public SortedSet<ILicenseFamily> getLicenseFamilies(LicenseFilter filter) {
public SortedSet<ILicenseFamily> getLicenseFamilies(final LicenseFilter filter) {
return setFactory.getLicenseFamilies(filter);
}

Expand All @@ -165,7 +163,7 @@ public SortedSet<ILicenseFamily> getLicenseFamilies(LicenseFilter filter) {
* @param filter define which type of licenses to return.
* @return The sorted set of approved licenseIds.
*/
public SortedSet<String> getLicenseIds(LicenseFilter filter) {
public SortedSet<String> getLicenseIds(final LicenseFilter filter) {
return setFactory.getLicenseFamilyIds(filter);
}

Expand All @@ -180,20 +178,20 @@ public static IOFileFilter getDirectoriesToIgnore() {
/**
* The Defaults builder.
*/
public static class Builder {
public final static class Builder {
private final Set<URL> fileNames = new TreeSet<>(Comparator.comparing(URL::toString));

private Builder() {
fileNames.add(DEFAULT_CONFIG_URL);
}

/**
* Adds a URL to a configuration file to be read.
* Adds a URI to a configuration file to be read.
*
* @param url the URL to add
* @return this Builder for chaining
*/
public Builder add(URL url) {
public Builder add(final URL url) {
fileNames.add(url);
return this;
}
Expand All @@ -205,7 +203,7 @@ public Builder add(URL url) {
* @return this Builder for chaining
* @throws MalformedURLException in case the fileName cannot be found.
*/
public Builder add(String fileName) throws MalformedURLException {
public Builder add(final String fileName) throws MalformedURLException {
return add(new File(fileName));
}

Expand All @@ -216,7 +214,7 @@ public Builder add(String fileName) throws MalformedURLException {
* @return this Builder for chaining
* @throws MalformedURLException in case the file cannot be found.
*/
public Builder add(File file) throws MalformedURLException {
public Builder add(final File file) throws MalformedURLException {
return add(file.toURI().toURL());
}

Expand All @@ -226,7 +224,7 @@ public Builder add(File file) throws MalformedURLException {
* @param url the URL of the file to remove.
* @return this Builder for chaining
*/
public Builder remove(URL url) {
public Builder remove(final URL url) {
fileNames.remove(url);
return this;
}
Expand All @@ -238,7 +236,7 @@ public Builder remove(URL url) {
* @return this Builder for chaining
* @throws MalformedURLException in case the fileName cannot be found.
*/
public Builder remove(String fileName) throws MalformedURLException {
public Builder remove(final String fileName) throws MalformedURLException {
return remove(new File(fileName));
}

Expand All @@ -249,7 +247,7 @@ public Builder remove(String fileName) throws MalformedURLException {
* @return this Builder for chaining
* @throws MalformedURLException in case the file cannot be found.
*/
public Builder remove(File file) throws MalformedURLException {
public Builder remove(final File file) throws MalformedURLException {
return remove(file.toURI().toURL());
}

Expand All @@ -267,7 +265,7 @@ public Builder noDefault() {
* @param log the Log to use to report errors when building the defaults.
* @return the current defaults object.
*/
public Defaults build(Log log) {
public Defaults build(final Log log) {
return new Defaults(log, fileNames);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@
import org.apache.rat.document.impl.guesser.NoteGuesser;
import org.apache.rat.utils.Log;
import org.apache.tika.Tika;
import org.apache.tika.metadata.HttpHeaders;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.TikaCoreProperties;
import org.apache.tika.mime.MediaType;
import org.apache.tika.mime.MimeType;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -40,11 +38,11 @@
public class TikaProcessor {

/** the Tika parser */
private static final Tika tika = new Tika();
private static final Tika TIKA = new Tika();
/** A map of mime type string to non BINARY types.
* "text" types are already handled everything else
* BINARY unless listed here*/
static Map<String, Document.Type> documentTypeMap;
private static Map<String, Document.Type> documentTypeMap;

static {
documentTypeMap = new HashMap<>();
Expand Down Expand Up @@ -102,11 +100,11 @@ public class TikaProcessor {
* @return the mimetype as a string.
* @throws RatDocumentAnalysisException on error.
*/
public static String process(Log log, Document document) throws RatDocumentAnalysisException {
public static String process(final Log log, final Document document) throws RatDocumentAnalysisException {
Metadata metadata = new Metadata();
try (InputStream stream = document.inputStream()) {
metadata.set(TikaCoreProperties.RESOURCE_NAME_KEY, document.getName());
String result = tika.detect(stream, metadata);
String result = TIKA.detect(stream, metadata);
String[] parts = result.split("/");
MediaType mediaType = new MediaType(parts[0], parts[1]);
document.getMetaData().setMediaType(mediaType);
Expand All @@ -124,7 +122,7 @@ public static String process(Log log, Document document) throws RatDocumentAnaly
}
}

public static Document.Type fromMediaType(MediaType mediaType, Log log) {
public static Document.Type fromMediaType(final MediaType mediaType, final Log log) {
if ("text".equals(mediaType.getType())) {
return Document.Type.STANDARD;
}
Expand Down

0 comments on commit 5414610

Please sign in to comment.