Skip to content

Commit

Permalink
refactor: improve code readability for ConstructorUtils, FieldsExtraU…
Browse files Browse the repository at this point in the history
…tils, MethodEnhancementsUtils, MiscellaneousUtils
  • Loading branch information
alxkm authored Sep 9, 2024
1 parent 1f37443 commit 3b5ec0e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/main/java/org/reflector/ConstructorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

public final class ConstructorUtils {

private static final Logger LOGGER = LoggerFactory.getLogger(ConstructorUtils.class);

private ConstructorUtils() {}

/**
Expand Down Expand Up @@ -38,9 +40,6 @@ public static int getConstructorModifiers(Constructor<?> constructor) {
return constructor.getModifiers();
}


private static final Logger LOGGER = LoggerFactory.getLogger(ConstructorUtils.class);

/**
* Retrieves all public constructors of the specified class.
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/reflector/FieldsExtraUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static List<Field> getAllAnnotatedFields(final Class<?> type, final Class
List<Field> annotatedFields = new ArrayList<>();
for (Field field : FieldUtils.getAllFields(type)) {
if (field.isAnnotationPresent(annotation)) {
field.setAccessible(true); // Ensure the field is accessible
field.setAccessible(true);
annotatedFields.add(field);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/reflector/MethodEnhancementsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private MethodEnhancementsUtils() {}
* @return a list of methods annotated with the specified annotation
* @throws NullPointerException if the clazz or annotationClass is null
*/
public static List<Method> getAnnotatedMethods(Class<?> clazz, Class<? extends Annotation> annotationClass) {
public static List<Method> getAnnotatedMethods(final Class<?> clazz, Class<? extends Annotation> annotationClass) {
if (clazz == null || annotationClass == null) {
throw new NullPointerException("Class and annotation class cannot be null");
}
Expand All @@ -40,7 +40,7 @@ public static List<Method> getAnnotatedMethods(Class<?> clazz, Class<? extends A
* @return a list of constructors annotated with the specified annotation
* @throws NullPointerException if the clazz or annotationClass is null
*/
public static List<Constructor<?>> getAnnotatedConstructors(Class<?> clazz, Class<? extends Annotation> annotationClass) {
public static List<Constructor<?>> getAnnotatedConstructors(final Class<?> clazz, Class<? extends Annotation> annotationClass) {
if (clazz == null || annotationClass == null) {
throw new NullPointerException("Class and annotation class cannot be null");
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/reflector/MiscellaneousUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ private MiscellaneousUtils() {}
* @return a new instance of the specified class
* @throws NullPointerException if the class is null
* @throws InstantiationException if the class represents an abstract class, an interface, an array class, a primitive type, or void;
* or if the class has no nullary constructor
* @throws IllegalAccessException if the class or its nullary constructor is not accessible
* @throws InvocationTargetException if the nullary constructor throws an exception
* or if the class has no nullable constructor
* @throws IllegalAccessException if the class or its nullable constructor is not accessible
* @throws InvocationTargetException if the nullable constructor throws an exception
*/
public static <T> T newInstance(Class<T> clazz) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
if (clazz == null) {
Expand Down

0 comments on commit 3b5ec0e

Please sign in to comment.