From 9f3a3520afd7559ee87dc144046618003ce74da8 Mon Sep 17 00:00:00 2001 From: marko-bekhta Date: Tue, 24 Jan 2023 13:36:22 +0100 Subject: [PATCH] Remove default value extraction --- .../properties/processor/AsciiDocWriter.java | 9 ------- .../processor/ConfigurationProperty.java | 15 +----------- .../ConfigurationPropertyCollector.java | 24 ------------------- 3 files changed, 1 insertion(+), 47 deletions(-) diff --git a/local-build-plugins/src/main/java/org/hibernate/orm/properties/processor/AsciiDocWriter.java b/local-build-plugins/src/main/java/org/hibernate/orm/properties/processor/AsciiDocWriter.java index 268616ec8b..c6be810001 100644 --- a/local-build-plugins/src/main/java/org/hibernate/orm/properties/processor/AsciiDocWriter.java +++ b/local-build-plugins/src/main/java/org/hibernate/orm/properties/processor/AsciiDocWriter.java @@ -12,7 +12,6 @@ import java.io.Writer; import java.util.Collection; import java.util.Iterator; import java.util.Map; -import java.util.Objects; import java.util.TreeMap; import java.util.TreeSet; import java.util.function.BiConsumer; @@ -69,14 +68,6 @@ public class AsciiDocWriter implements BiConsumer private HibernateOrmConfiguration.Type type; - private Object defaultValue; - private String anchorPrefix; private String moduleName; @@ -65,15 +63,6 @@ public class ConfigurationProperty implements Comparable return this; } - public Object defaultValue() { - return defaultValue; - } - - public ConfigurationProperty defaultValue(Object defaultValue) { - this.defaultValue = defaultValue == null ? "" : defaultValue; - return this; - } - public String anchorPrefix() { return anchorPrefix; } @@ -99,7 +88,6 @@ public class ConfigurationProperty implements Comparable ", javadoc='" + javadoc + '\'' + ", sourceClass='" + sourceClass + '\'' + ", type='" + type + '\'' + - ", default='" + defaultValue + '\'' + ", anchorPrefix='" + anchorPrefix + '\'' + ", moduleName='" + moduleName + '\'' + '}'; @@ -123,14 +111,13 @@ public class ConfigurationProperty implements Comparable Objects.equals( javadoc, that.javadoc ) && Objects.equals( sourceClass, that.sourceClass ) && type == that.type && - Objects.equals( defaultValue, that.defaultValue ) && Objects.equals( anchorPrefix, that.anchorPrefix ) && Objects.equals( moduleName, that.moduleName ); } @Override public int hashCode() { - return Objects.hash( key, javadoc, sourceClass, type, defaultValue, anchorPrefix, moduleName ); + return Objects.hash( key, javadoc, sourceClass, type, anchorPrefix, moduleName ); } public static class Key { diff --git a/local-build-plugins/src/main/java/org/hibernate/orm/properties/processor/ConfigurationPropertyCollector.java b/local-build-plugins/src/main/java/org/hibernate/orm/properties/processor/ConfigurationPropertyCollector.java index cf0a60bc7a..39a553d4c2 100644 --- a/local-build-plugins/src/main/java/org/hibernate/orm/properties/processor/ConfigurationPropertyCollector.java +++ b/local-build-plugins/src/main/java/org/hibernate/orm/properties/processor/ConfigurationPropertyCollector.java @@ -100,10 +100,6 @@ public class ConfigurationPropertyCollector { annotation.flatMap( a -> a.multiAttribute( "prefix", String.class ) ) ); if ( !key.matches( ignoreKeys ) ) { - // Try to find a default value. Assumption is that the settings class has an inner class called "Defaults" and - // the key for the default value is exactly the same as the config constant name: - Object value = findDefault( constant ); - properties.put( constant.getEnclosingElement().toString() + "#" + constant.getSimpleName().toString(), new ConfigurationProperty() @@ -111,7 +107,6 @@ public class ConfigurationPropertyCollector { .key( key ) .sourceClass( constant.getEnclosingElement().toString() ) .type( extractType( constant ) ) - .defaultValue( value ) .withModuleName( title.orElse( classTitle.orElse( this.title ) ) ) .withAnchorPrefix( anchorPrefix.orElse( classAnchorPrefix.orElse( this.anchor ) ) ) ); @@ -195,25 +190,6 @@ public class ConfigurationPropertyCollector { } } - /** - * This really works only for string/primitive constants ... other types would just get null returned. - */ - private Object findDefault(VariableElement constant) { - if ( constant.getEnclosingElement() instanceof TypeElement ) { - for ( Element element : elementUtils.getAllMembers( (TypeElement) constant.getEnclosingElement() ) ) { - if ( ElementKind.CLASS.equals( element.getKind() ) - && element.getSimpleName().contentEquals( "Defaults" ) ) { - for ( Element enclosedElement : element.getEnclosedElements() ) { - if ( enclosedElement.getSimpleName().equals( constant.getSimpleName() ) ) { - return ( (VariableElement) enclosedElement ).getConstantValue(); - } - } - } - } - } - return null; - } - private PackageElement packageElement(Element element) { Element packageElement = element; while ( !( packageElement instanceof PackageElement ) && packageElement.getEnclosingElement() != null ) {