From 9ab764c2e2f960370ee4d4704fbe5d9c528a5aca Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Fri, 7 May 2021 01:00:20 +0200 Subject: [PATCH] Fixed compile issues in COnfigurator --- src/zutil/ui/Configurator.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/zutil/ui/Configurator.java b/src/zutil/ui/Configurator.java index 06bad08..4e55c9f 100755 --- a/src/zutil/ui/Configurator.java +++ b/src/zutil/ui/Configurator.java @@ -75,11 +75,11 @@ public class Configurator { /** Nice name of this parameter **/ String value(); /** A longer human friendly description of the parameter **/ - String description(); + String description() default ""; /** Defines the order the parameter, parameter with lowest order value will be shown first **/ int order() default Integer.MAX_VALUE; /** Provide a custom set of values through a value provider that will be the choice the user will have. **/ - Class valueProvider(); + Class valueProvider() default DummyValueProvider.class; } /** @@ -316,6 +316,9 @@ public class Configurator { } private ConfigValueProvider getValueProviderInstance(Class valueProviderClass) throws ReflectiveOperationException { + if (DummyValueProvider.class.equals(valueProviderClass)) + return null; + for (Constructor constructor : valueProviderClass.getConstructors()) { switch (constructor.getParameterCount()) { case 0: return valueProviderClass.getDeclaredConstructor().newInstance(); @@ -392,4 +395,14 @@ public class Configurator { return this.order - configurationParam.order; } } + + /** + * This is a default class that only indicates that no ValueProvider has been given in the {@link Configurable} annotation. + */ + private static class DummyValueProvider implements ConfigValueProvider { + @Override + public String[] getPossibleValues() {return new String[0];} + @Override + public Object getValueObject(String value) {return null;} + } }