Search in sources :

Example 1 with SettingGroup

use of org.neo4j.graphdb.config.SettingGroup in project neo4j by neo4j.

the class LoadableConfig method getConfigOptions.

/**
     * Collects settings from implementors which may or may not have descriptions attached to them.
     *
     * @return a list of the implementing class's ConfigOptions
     */
default default List<ConfigOptions> getConfigOptions() {
    ArrayList<ConfigOptions> configOptions = new ArrayList<>();
    for (Field f : getClass().getDeclaredFields()) {
        try {
            Object publicSetting = f.get(this);
            if (publicSetting instanceof BaseSetting) {
                BaseSetting setting = (BaseSetting) publicSetting;
                final Description documentation = f.getAnnotation(Description.class);
                if (documentation != null) {
                    setting.setDescription(documentation.value());
                }
                final DocumentedDefaultValue defValue = f.getAnnotation(DocumentedDefaultValue.class);
                if (defValue != null) {
                    setting.setDocumentedDefaultValue(defValue.value());
                }
                final Deprecated deprecatedAnnotation = f.getAnnotation(Deprecated.class);
                setting.setDeprecated(deprecatedAnnotation != null);
                final ReplacedBy replacedByAnnotation = f.getAnnotation(ReplacedBy.class);
                if (replacedByAnnotation != null) {
                    setting.setReplacement(replacedByAnnotation.value());
                }
                final Internal internalAnnotation = f.getAnnotation(Internal.class);
                setting.setInternal(internalAnnotation != null);
            }
            if (publicSetting instanceof SettingGroup) {
                SettingGroup setting = (SettingGroup) publicSetting;
                configOptions.add(new ConfigOptions(setting));
            }
        } catch (IllegalAccessException ignored) {
            // Field is private, ignore it
            continue;
        }
    }
    return configOptions;
}
Also used : ArrayList(java.util.ArrayList) BaseSetting(org.neo4j.graphdb.config.BaseSetting) SettingGroup(org.neo4j.graphdb.config.SettingGroup) Field(java.lang.reflect.Field)

Aggregations

Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 BaseSetting (org.neo4j.graphdb.config.BaseSetting)1 SettingGroup (org.neo4j.graphdb.config.SettingGroup)1