Remove default value extraction
This commit is contained in:
parent
8fa8b23d63
commit
9f3a3520af
|
@ -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<Map<String, ConfigurationPrope
|
|||
writer.write( el.javadoc() );
|
||||
writer.write( " +++ " );
|
||||
|
||||
String defaultValue = Objects.toString( el.defaultValue(), "" );
|
||||
if ( !defaultValue.trim().isEmpty() ) {
|
||||
writer.write( "\n+\n" );
|
||||
writer.write( "Default value: `" );
|
||||
writer.write( defaultValue );
|
||||
writer.write( '`' );
|
||||
}
|
||||
|
||||
writer.write( '\n' );
|
||||
|
||||
printOtherKeyVariants( writer, keys );
|
||||
|
|
|
@ -24,8 +24,6 @@ public class ConfigurationProperty implements Comparable<ConfigurationProperty>
|
|||
|
||||
private HibernateOrmConfiguration.Type type;
|
||||
|
||||
private Object defaultValue;
|
||||
|
||||
private String anchorPrefix;
|
||||
private String moduleName;
|
||||
|
||||
|
@ -65,15 +63,6 @@ public class ConfigurationProperty implements Comparable<ConfigurationProperty>
|
|||
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<ConfigurationProperty>
|
|||
", javadoc='" + javadoc + '\'' +
|
||||
", sourceClass='" + sourceClass + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
", default='" + defaultValue + '\'' +
|
||||
", anchorPrefix='" + anchorPrefix + '\'' +
|
||||
", moduleName='" + moduleName + '\'' +
|
||||
'}';
|
||||
|
@ -123,14 +111,13 @@ public class ConfigurationProperty implements Comparable<ConfigurationProperty>
|
|||
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 {
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
Loading…
Reference in New Issue