Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-schnell committed Dec 23, 2023
1 parent 39fae1a commit 680cc58
Show file tree
Hide file tree
Showing 60 changed files with 188 additions and 292 deletions.
7 changes: 1 addition & 6 deletions src/main/java/org/fuin/utils4j/ChangeTrackingMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
*/
package org.fuin.utils4j;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.*;

/**
* A wrapper for maps that keeps track of all changes made to the map since construction. Only adding, replacing or deleting elements is
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/org/fuin/utils4j/ChangeTrackingUniqueList.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
*/
package org.fuin.utils4j;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.*;

/**
* A wrapper for lists that keeps track of all changes made to the list since construction. Only adding, replacing or deleting elements is
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/fuin/utils4j/JandexUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.fuin.utils4j;

import org.jboss.jandex.Indexer;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -25,8 +27,6 @@
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import org.jboss.jandex.Indexer;

/**
* Utilities related to Jandex.
*/
Expand Down
15 changes: 2 additions & 13 deletions src/main/java/org/fuin/utils4j/PropertiesFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,9 @@
*/
package org.fuin.utils4j;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.io.*;
import java.nio.channels.FileLock;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.*;

/**
* A properties file that is capable of merging concurrent changes made by another JVM or another process.
Expand Down
14 changes: 3 additions & 11 deletions src/main/java/org/fuin/utils4j/PropertiesUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,13 @@
*/
package org.fuin.utils4j;

import static org.fuin.utils4j.Utils4J.checkNotNull;
import static org.fuin.utils4j.Utils4J.checkValidFile;
import static org.fuin.utils4j.Utils4J.createUrl;
import static org.fuin.utils4j.Utils4J.getPackagePath;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;

import static org.fuin.utils4j.Utils4J.*;

/**
* Utilities related to the {@link Properties} class.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
*/
package org.fuin.utils4j;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.io.*;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
*/
package org.fuin.utils4j;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.io.*;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;

Expand Down
39 changes: 7 additions & 32 deletions src/main/java/org/fuin/utils4j/Utils4J.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,12 @@
*/
package org.fuin.utils4j;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
import java.io.Reader;
import java.io.Writer;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
Expand All @@ -48,25 +35,13 @@
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;

import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;

/**
* Common utility methods for use in Java applications and libraries.
*/
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/org/fuin/utils4j/VariableResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@
*/
package org.fuin.utils4j;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;

/**
* Resolves the references from variable values to other variable names.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/fuin/utils4j/filter/ComparableFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
*/
package org.fuin.utils4j.filter;

import org.fuin.utils4j.Utils4J;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.fuin.utils4j.Utils4J;

/**
* Defines a filter on a Comparable value.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/fuin/utils4j/filter/RegExprFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public class RegExprFilter implements Filter {
private static final String[] TYPES = new String[] { "matches", "lookingAt", "find" };

/** Compiled pattern. */
private Pattern p = null;
private Pattern p;

/** String pattern to apply. */
private String pattern = null;
private String pattern;

/** Type of matching. */
private int type = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/fuin/utils4j/filter/StringFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
*/
package org.fuin.utils4j.filter;

import org.fuin.utils4j.Utils4J;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.fuin.utils4j.Utils4J;

/**
* Defines a filter on a String.
*/
Expand Down
14 changes: 3 additions & 11 deletions src/main/java/org/fuin/utils4j/jaxb/JaxbUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,16 @@
*/
package org.fuin.utils4j.jaxb;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;

import javax.xml.stream.XMLStreamWriter;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;

import org.fuin.utils4j.Utils4J;

import javax.xml.stream.XMLStreamWriter;
import java.io.*;

/**
* JAXB releated functions.
*/
Expand Down
22 changes: 6 additions & 16 deletions src/main/java/org/fuin/utils4j/jaxb/UnmarshallerBuilder.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
package org.fuin.utils4j.jaxb;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import jakarta.xml.bind.*;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import org.fuin.utils4j.Utils4J;
import org.xml.sax.SAXException;

import javax.xml.XMLConstants;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.PropertyException;
import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.ValidationEventHandler;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;

import org.fuin.utils4j.Utils4J;
import org.xml.sax.SAXException;
import java.util.*;

/**
* Builder that helps creating an {@link Unmarshaller} instance.
Expand Down Expand Up @@ -290,6 +279,7 @@ private static void setProperties(final Unmarshaller unmarshaller, final Map<Str
private Schema createSchema() {
final SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
return factory.newSchema(schemaSources.toArray(new Source[schemaSources.size()]));
} catch (final SAXException ex) {
throw new RuntimeException("Failed to create schema", ex);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/fuin/utils4j/CancelableVolatileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
*/
package org.fuin.utils4j;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

// CHECKSTYLE:OFF
public class CancelableVolatileTest {

Expand Down
Loading

0 comments on commit 680cc58

Please sign in to comment.