Merge pull request #2820 from andreykaipov/feature/config-inheritance
configmanager: write all of our config items to our properties
This commit is contained in:
@@ -49,12 +49,16 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import java.util.Stack;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -695,7 +699,7 @@ public class ConfigManager
|
||||
return;
|
||||
}
|
||||
|
||||
for (Method method : clazz.getDeclaredMethods())
|
||||
for (Method method : getAllDeclaredInterfaceMethods(clazz))
|
||||
{
|
||||
ConfigItem item = method.getAnnotation(ConfigItem.class);
|
||||
|
||||
@@ -813,6 +817,25 @@ public class ConfigManager
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does DFS on a class's interfaces to find all of its implemented methods.
|
||||
*/
|
||||
private Collection<Method> getAllDeclaredInterfaceMethods(Class<?> clazz)
|
||||
{
|
||||
Collection<Method> methods = new HashSet<>();
|
||||
Stack<Class<?>> interfazes = new Stack<>();
|
||||
interfazes.push(clazz);
|
||||
|
||||
while (!interfazes.isEmpty())
|
||||
{
|
||||
Class<?> interfaze = interfazes.pop();
|
||||
Collections.addAll(methods, interfaze.getDeclaredMethods());
|
||||
Collections.addAll(interfazes, interfaze.getInterfaces());
|
||||
}
|
||||
|
||||
return methods;
|
||||
}
|
||||
|
||||
private void syncLastModified()
|
||||
{
|
||||
File newestFile;
|
||||
|
||||
Reference in New Issue
Block a user