public ConfigurationMetadataProperty createConfigurationProperty ( final FieldDeclaration fieldDecl , final String propName ) { val variable = fieldDecl . getVariables ( ) . get ( 0 ) ; val name = StreamSupport . stream ( RelaxedPropertyNames . forCamelCase ( variable . getNameAsString ( ) ) . spliterator ( ) , false ) . map ( Object :: toString ) . findFirst ( ) . orElseGet ( variable :: getNameAsString ) ; val indexedGroup = propName . concat ( indexNameWithBrackets ? "[]" : StringUtils . EMPTY ) ; val indexedName = indexedGroup . concat ( "." ) . concat ( name ) ; val prop = new ConfigurationMetadataProperty ( ) ; if ( fieldDecl . getJavadoc ( ) . isPresent ( ) ) { val description = fieldDecl . getJavadoc ( ) . get ( ) . getDescription ( ) . toText ( ) ; prop . setDescription ( description ) ; prop . setShortDescription ( StringUtils . substringBefore ( description , "." ) ) ; } else { LOGGER . error ( "No Javadoc found for field [{}]" , indexedName ) ; } prop . setName ( indexedName ) ; prop . setId ( indexedName ) ; val elementType = fieldDecl . getElementType ( ) . asString ( ) ; if ( elementType . equals ( String . class . getSimpleName ( ) ) || elementType . equals ( Integer . class . getSimpleName ( ) ) || elementType . equals ( Long . class . getSimpleName ( ) ) || elementType . equals ( Double . class . getSimpleName ( ) ) || elementType . equals ( Float . class . getSimpleName ( ) ) ) { prop . setType ( "java.lang." + elementType ) ; } else { prop . setType ( elementType ) ; } val initializer = variable . getInitializer ( ) ; if ( initializer . isPresent ( ) ) { val exp = initializer . get ( ) ; if ( exp instanceof LiteralStringValueExpr ) { prop . setDefaultValue ( ( ( LiteralStringValueExpr ) exp ) . getValue ( ) ) ; } else if ( exp instanceof BooleanLiteralExpr ) { prop . setDefaultValue ( ( ( BooleanLiteralExpr ) exp ) . getValue ( ) ) ; } } properties . add ( prop ) ; val grp = new ConfigurationMetadataProperty ( ) ; grp . setId ( indexedGroup ) ; grp . setName ( indexedGroup ) ; grp . setType ( parentClass ) ; groups . add ( grp ) ; return prop ; }
Create configuration property .