Skip to content

Commit

Permalink
Update java version to 21, update libraries, fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Knell committed Feb 21, 2024
1 parent bf47bf2 commit df320b5
Show file tree
Hide file tree
Showing 29 changed files with 247 additions and 319 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '8' ]
java: [ '21' ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK
Expand All @@ -28,14 +28,14 @@ jobs:
- name: Compile
run: ./mvnw --batch-mode clean compile
build:
name: build with jdk 8
name: build with jdk 21
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 8
java-version: 21
- uses: actions/cache@v2
with:
path: ~/.m2/repository
Expand Down
36 changes: 17 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>

<licenses>
Expand Down Expand Up @@ -74,51 +74,49 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
<version>2.0.12</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.6.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.5.15</version>
<version>5.10.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.3</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl </artifactId>
<version>2.13.3</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<version>3.0.1</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
</configuration>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/synyx/beanfiller/BeanFiller.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public <T> T fillBean(Class<T> clazz) throws FillingException {
* @param clazz class for which the creator should be used
* @param creator creator that should be used for the given class
*/
public void addCreator(Class clazz, Creator creator) {
public void addCreator(Class<?> clazz, Creator creator) {

if (clazz == null || creator == null) {
LOG.warn("Class or Creator is null, abort adding the Creator!");
Expand All @@ -137,7 +137,7 @@ public void addCreator(Class clazz, Creator creator) {
* @param attributeName attribute for which the creator should be used
* @param creator creator that should be used for the given attribute of the given class
*/
public void addCreatorForClassAndAttribute(Class clazz, String attributeName, Creator creator) {
public void addCreatorForClassAndAttribute(Class<?> clazz, String attributeName, Creator creator) {

if (clazz == null || attributeName == null || creator == null) {
LOG.warn("Class, attributeName, or Creator is null, abort adding the creator!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface ArrayCreator extends Creator {
*
* @throws FillingException if an error occurred.
*/
Object createArray(List<Object> objects, Class arrayType) throws FillingException;
Object createArray(List<?> objects, Class<?> arrayType) throws FillingException;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ public interface EnumCreator extends Creator {
*
* @throws FillingException if an error occurred.
*/
Object createEnum(Class clazz) throws FillingException;
Object createEnum(Class<?> clazz) throws FillingException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public SimpleArrayCreator(ArrayCriteria arrayCriteria) {
}

@Override
public Object createArray(List<Object> objects, Class arrayType) {
public Object createArray(List<?> objects, Class<?> arrayType) {

// create a new instance of the array with the given type
Object array = Array.newInstance(arrayType, getSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class SimpleEnumCreator implements EnumCreator {

@Override
public Object createEnum(Class clazz) throws NoEnumConstantsException {
public Object createEnum(Class<?> clazz) throws NoEnumConstantsException {

Object[] enumArray = clazz.getEnumConstants();

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/synyx/beanfiller/domain/History.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class History {

private static final Logger LOG = LoggerFactory.getLogger(History.class);
private List<Class> filledClasses;
private List<Class<?>> filledClasses;
private boolean isRepeating = false;

/**
Expand Down Expand Up @@ -51,13 +51,13 @@ public History(History parent) {
*
* @return List of previously filled classes.
*/
public List<Class> getFilledClasses() {
public List<Class<?>> getFilledClasses() {

return new ArrayList<>(filledClasses);
}


public void setFilledClasses(List<Class> filledClasses) {
public void setFilledClasses(List<Class<?>> filledClasses) {

this.filledClasses = filledClasses;
}
Expand Down Expand Up @@ -92,7 +92,7 @@ public boolean isRepeating() {
*/
private void update(ObjectInformation objectInformation) {

Class currentClass = objectInformation.getClazz();
Class<?> currentClass = objectInformation.getClazz();
Field currentField = objectInformation.getField();
checkForCycle(currentClass, currentField);

Expand All @@ -106,17 +106,17 @@ private void update(ObjectInformation objectInformation) {
* @param currentClass the current class to check.
* @param currentField the current field to check.
*/
private void checkForCycle(Class currentClass, Field currentField) {
private void checkForCycle(Class<?> currentClass, Field currentField) {

List<Class> classesToCheck = new ArrayList<>();
List<Class<?>> classesToCheck = new ArrayList<>();
classesToCheck.add(currentClass);

// we also have to check for the actual type arguments for the case we have a class with generics.
List<Type> actualTypeArguments = GenericsUtils.getActualTypeArguments(currentField);

for (Type type : actualTypeArguments) {
try {
Class clazz = GenericsUtils.getClassForType(type);
Class<?> clazz = GenericsUtils.getClassForType(type);

classesToCheck.add(clazz);
} catch (ClassNotFoundException ex) {
Expand All @@ -126,7 +126,7 @@ private void checkForCycle(Class currentClass, Field currentField) {
}

// if one of the classes is contained in the history, the given objectInformation is creating a cycle.
for (Class clazz : classesToCheck) {
for (Class<?> clazz : classesToCheck) {
if (filledClasses.contains(clazz)) {
isRepeating = true;

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/synyx/beanfiller/services/BeanAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public class BeanAnalyzer {
*
* @return List of ObjectInformation from the given class.
*/
public static List<ObjectInformation> analyzeBean(Class clazz) {
public static List<ObjectInformation> analyzeBean(Class<?> clazz) {

List<ObjectInformation> objectInformation = new ArrayList<ObjectInformation>();
List<ObjectInformation> objectInformation = new ArrayList<>();

String path = clazz.getSimpleName();

Expand All @@ -48,7 +48,7 @@ public static List<ObjectInformation> analyzeBean(Class clazz) {

if (setter != null) {
// get the parameter type of the setter
Class parameterClazz = setter.getParameterTypes()[0];
Class<?> parameterClazz = setter.getParameterTypes()[0];

ObjectInformation parameterObjectInformation = new ObjectInformation(parameterClazz, field,
field.getType(), setter, fieldPath, null);
Expand All @@ -68,7 +68,7 @@ public static List<ObjectInformation> analyzeBean(Class clazz) {
*
* @return Map of the setters.
*/
private static Map<String, Method> getSetters(Class clazz) {
private static Map<String, Method> getSetters(Class<?> clazz) {

// get the methods of the class
Method[] methods = clazz.getMethods();
Expand All @@ -78,7 +78,7 @@ private static Map<String, Method> getSetters(Class clazz) {
for (Method method : methods) {
// method name start with set, it is public and it has exactly one parameter.
if (method.getName().startsWith("set") && Modifier.isPublic(method.getModifiers())
&& method.getParameterTypes() != null && method.getParameterTypes().length == 1) {
&& method.getParameterTypes().length == 1) {
setters.put(method.getName().toLowerCase(), method);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/synyx/beanfiller/services/CreatorRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public CreatorRegistry(Map<String, Creator> creatorMap) {
* @param attributeName attribute name the creator should be used on
* @param creator creator to add.
*/
public void addCreatorForClassAndAttribute(Class clazz, String attributeName, Creator creator) {
public void addCreatorForClassAndAttribute(Class<?> clazz, String attributeName, Creator creator) {

classAndAttributeSpecificCreatorMap.put(clazz.getName() + "." + attributeName, creator);
}
Expand All @@ -47,7 +47,7 @@ public void addCreatorForClassAndAttribute(Class clazz, String attributeName, Cr
* @param clazz class to use the creator on.
* @param creator creator to add.
*/
public void addCreator(Class clazz, Creator creator) {
public void addCreator(Class<?> clazz, Creator creator) {

creatorMap.put(clazz.getName(), creator);
}
Expand All @@ -61,7 +61,7 @@ public void addCreator(Class clazz, Creator creator) {
*
* @return a Creator or null if none was found.
*/
public Creator getCreator(Class clazz, Field field) {
public Creator getCreator(Class<?> clazz, Field field) {

Creator c = null;

Expand All @@ -86,7 +86,7 @@ public Creator getCreator(Class clazz, Field field) {
*
* @return the Creator or null, if none was found for this combination
*/
private Creator getSpecificCreator(Class clazz, Field field) {
private Creator getSpecificCreator(Class<?> clazz, Field field) {

// get the creator for the class and attribute
return classAndAttributeSpecificCreatorMap.get(clazz.getName() + "." + field.getName());
Expand All @@ -100,7 +100,7 @@ private Creator getSpecificCreator(Class clazz, Field field) {
*
* @return the Creator if found, or null.
*/
public Creator getCreatorForClass(Class clazz) {
public Creator getCreatorForClass(Class<?> clazz) {

// if no specific creator for this field was set, get the creator for the class of the parameter
// (class name because of primitive types)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public int compareTo(AbstractCreatorStrategy o) {
*
* @return true if the given class is an enum, false otherwise.
*/
protected boolean isEnum(Class clazz) {
protected boolean isEnum(Class<?> clazz) {

return clazz.isEnum();
}
Expand All @@ -190,7 +190,7 @@ protected boolean isEnum(Class clazz) {
*
* @return true if the given class is an array, false otherwise.
*/
protected boolean isArray(Class clazz) {
protected boolean isArray(Class<?> clazz) {

return clazz.isArray();
}
Expand All @@ -203,7 +203,7 @@ protected boolean isArray(Class clazz) {
*
* @return true if the given class is a collection, false otherwise.
*/
protected boolean isCollection(Class clazz) {
protected boolean isCollection(Class<?> clazz) {

return Collection.class.isAssignableFrom(clazz);
}
Expand Down Expand Up @@ -318,7 +318,7 @@ private ObjectInformation createObjectInformationForType(Type type, ObjectInform
throws FillingException {

try {
Class clazz = GenericsUtils.getClassForType(type);
Class<?> clazz = GenericsUtils.getClassForType(type);

return new ObjectInformation(clazz, parentObjectInformation.getField(), type, null, null,
parentObjectInformation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public Object createObjectInternal(ObjectInformation objectInformation) throws F

ArrayCreator arrayCreator = (ArrayCreator) creator;

Class arrayType = objectInformation.getClazz().getComponentType();
Class<?> arrayType = objectInformation.getClazz().getComponentType();

List<Object> objectsForArray = createObjectsForArray(arrayType, objectInformation.getField(),
List<?> objectsForArray = createObjectsForArray(arrayType, objectInformation.getField(),
arrayCreator.getSize(), objectInformation);

return arrayCreator.createArray(objectsForArray, arrayType);
Expand Down
Loading

0 comments on commit df320b5

Please sign in to comment.