Skip to content

Commit 8f13b27

Browse files
committed
clean clean
1 parent efaf732 commit 8f13b27

File tree

1 file changed

+1
-35
lines changed

1 file changed

+1
-35
lines changed

src/main/java/net/discordjug/javabot/data/config/ReflectionUtils.java

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,13 @@
1111
import java.lang.reflect.Field;
1212
import java.lang.reflect.Modifier;
1313
import java.util.Arrays;
14-
import java.util.HashMap;
15-
import java.util.Map;
1614
import java.util.Optional;
17-
import java.util.function.Function;
1815

1916
/**
2017
* Utility class for resolving JSON files.
2118
*/
2219
@Slf4j
2320
public class ReflectionUtils {
24-
private static final Map<Class<?>, Function<String, Object>> propertyTypeParsers = new HashMap<>();
25-
2621
private ReflectionUtils() {
2722
}
2823

@@ -80,36 +75,7 @@ private static Field findDeclaredField(Class<?> cl, String name) throws NoSuchFi
8075
}
8176

8277
/**
83-
* Gets a mapping of properties and their type, recursively for the given
84-
* type.
85-
*
86-
* @param parentPropertyName The root property name to append child field
87-
* names to. This is null for the base case.
88-
* @param parentClass The class to search for properties in.
89-
* @return The map of properties and their types.
90-
* @throws IllegalAccessException If a field cannot have its value obtained.
91-
*/
92-
public static @NotNull Map<String, Class<?>> getFields(@NotNull String parentPropertyName, @NotNull Class<?> parentClass) throws IllegalAccessException {
93-
Map<String, Class<?>> fieldsMap = new HashMap<>();
94-
for (Field field : parentClass.getDeclaredFields()) {
95-
// Skip transient fields.
96-
if (Modifier.isTransient(field.getModifiers()) || Modifier.isStatic(field.getModifiers())) continue;
97-
field.setAccessible(true);
98-
String fieldPropertyName = parentPropertyName == null ? field.getName() : parentPropertyName + "." + field.getName();
99-
// Check if the field represents a "leaf" property, one which does not have any children.
100-
if (propertyTypeParsers.containsKey(field.getType())) {
101-
fieldsMap.put(fieldPropertyName, field.getType());
102-
} else {
103-
Map<String, Class<?>> childFieldsMap = getFields(fieldPropertyName, field.getType());
104-
fieldsMap.putAll(childFieldsMap);
105-
}
106-
}
107-
return fieldsMap;
108-
}
109-
110-
/**
111-
* Sets the value of a field to a certain value, using {@link ReflectionUtils#propertyTypeParsers}
112-
* to try and parse the correct value.
78+
* Sets the value of a field to a new value.
11379
*
11480
* @param field The field to set.
11581
* @param parent The object whose property value to set.

0 commit comments

Comments
 (0)