Skip to content

Commit

Permalink
Add javadocs to utility classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Koboo committed Jan 27, 2023
1 parent dcca06c commit 93bce40
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/eu/koboo/en2do/utility/AnnotationUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@
import java.util.HashSet;
import java.util.Set;

/**
* A utility class for everything related to annotations
*/
@UtilityClass
public class AnnotationUtils {

/**
* This method is ued to get all annotations from an entity class, using while loop,
* to iterate through all super-types.
* @param entityClass The class, which should be scanned.
* @param annotationClass the searched annotation
* @return The Set with all found annotations of type A
* @param <E> The generic type of the Class
* @param <A> The generic type of the annotation Class
*/
public <E, A extends Annotation> Set<A> collectAnnotations(Class<E> entityClass, Class<A> annotationClass) {
Set<A> annotationSet = new HashSet<>();
Class<?> clazz = entityClass;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/eu/koboo/en2do/utility/DateUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;

/**
* A utility class for working with "java.util.Date".
*/
@UtilityClass
@SuppressWarnings("unused")
public class DateUtils {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/eu/koboo/en2do/utility/EntityUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@
import java.util.Arrays;
import java.util.List;

/**
* A utility class for everything related to entity properties.
*/
@UtilityClass
public class EntityUtils {

/**
* This method is used to copy all field values from one entity to another.
* It also works with inheritance.
* @param from The entity to copy from
* @param to The entity to copy to
*/
public void copyProperties(Object from, Object to) {
Class<?> fromClass = from.getClass();
Class<?> toClass = to.getClass();
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/eu/koboo/en2do/utility/FieldUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@
import java.util.HashSet;
import java.util.Set;

/**
* A utility class for everything related to fields.
*/
@UtilityClass
public class FieldUtils {

/**
* This method is used to scan a class for all fields.
* @param typeClass The class, which should be scanned
* @return The Set with all found fields of the given class.
* @param <E> The generic type of the class
*/
public <E> Set<Field> collectFields(Class<E> typeClass) {
Set<Field> fields = new HashSet<>();
Class<?> clazz = typeClass;
Expand All @@ -24,6 +33,12 @@ public <E> Set<Field> collectFields(Class<E> typeClass) {
return fields;
}

/**
* This method is used to iterate through a set of fields and search for a field by its name.
* @param fieldName The field name, which should be searched.
* @param fieldSet The Set, which should be iterated through
* @return The field, if found. If not found, it returns "null"
*/
public Field findFieldByName(String fieldName, Set<Field> fieldSet) {
for (Field field : fieldSet) {
if (!field.getName().equalsIgnoreCase(fieldName)) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/eu/koboo/en2do/utility/GenericUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
* A utility class for everything related to generic types or class types.
*/
@UtilityClass
public class GenericUtils {

Expand Down

0 comments on commit 93bce40

Please sign in to comment.