Skip to content

Commit

Permalink
Update INIConfig.java
Browse files Browse the repository at this point in the history
Adjust the ini configuration format.
  • Loading branch information
BytingBulldogs3539 committed Feb 4, 2023
1 parent 40866dd commit 4cba88a
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,23 @@ public INIConfig(String filename) {
public void autoPopulate(Object o) {
if (ini != null) {
Field[] fields = o.getClass().getFields();
String className = o.getClass().getSimpleName();

for (Field field : fields) {
String[] split = field.getName().split("_");
int length = split.length;
if (length >= 2) {
try {

if(getOrDefault(split[split.length - 2], split[split.length - 1], null, field.getType())!=null)
{
field.set(o,
getOrDefault(split[split.length - 2], split[split.length - 1], null, field.getType()));
}

} catch (IllegalArgumentException | IllegalAccessException e) {
DriverStation.reportWarning("Could not load item " + field.getName() + " from file " + filename,
e.getStackTrace());
String fieldName = field.getName();

try {
if (getOrDefault(className, fieldName, null, field.getType()) != null) {
field.setAccessible(true);

field.set(o, getOrDefault(className, fieldName, null, field.getType()));

}

} catch (IllegalArgumentException | IllegalAccessException e) {
DriverStation.reportWarning("Could not load item " + field.getName() + " from file " + filename,
e.getStackTrace());
}
field.getType();
}
}
}
Expand Down

0 comments on commit 4cba88a

Please sign in to comment.