Skip to content

Commit

Permalink
Fix styles
Browse files Browse the repository at this point in the history
  • Loading branch information
Yauhenikapl committed Oct 31, 2024
1 parent 124f425 commit 0d1f312
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,24 @@ private static String determineCollectionType( final Collection collection, fina

if ( collection.isAllowDuplicates() && collection.isOrdered() ) {
codeGenerationConfig.importTracker().importExplicit( List.class );
return containerType( List.class, getDataType( dataType, codeGenerationConfig.importTracker(), codeGenerationConfig ), elementConstraint );
return containerType( List.class, getDataType( dataType, codeGenerationConfig.importTracker(), codeGenerationConfig ),
elementConstraint );
}
if ( !collection.isAllowDuplicates() && collection.isOrdered() ) {
codeGenerationConfig.importTracker().importExplicit( LinkedHashSet.class );
return containerType( LinkedHashSet.class, getDataType( dataType, codeGenerationConfig.importTracker(), codeGenerationConfig ), elementConstraint );
return containerType( LinkedHashSet.class, getDataType( dataType, codeGenerationConfig.importTracker(), codeGenerationConfig ),
elementConstraint );
}
if ( collection.isAllowDuplicates() && !collection.isOrdered() ) {
codeGenerationConfig.importTracker().importExplicit( java.util.Collection.class );
return containerType( java.util.Collection.class, getDataType( dataType, codeGenerationConfig.importTracker(), codeGenerationConfig ),
return containerType( java.util.Collection.class,
getDataType( dataType, codeGenerationConfig.importTracker(), codeGenerationConfig ),
elementConstraint );
}
if ( !collection.isAllowDuplicates() && !collection.isOrdered() ) {
codeGenerationConfig.importTracker().importExplicit( Set.class );
return containerType( Set.class, getDataType( dataType, codeGenerationConfig.importTracker(), codeGenerationConfig ), elementConstraint );
return containerType( Set.class, getDataType( dataType, codeGenerationConfig.importTracker(), codeGenerationConfig ),
elementConstraint );
}
throw new CodeGenerationException( "Could not determine Java collection type for " + collection.getName() );
}
Expand All @@ -304,12 +308,13 @@ public static String containerType( final Class<?> containerClass, final String
* @param importTracker the import tracker
* @return a {@link String} containing the definition of the Java Data Type
*/
public static String getDataType( final Optional<Type> dataType, final ImportTracker importTracker, final JavaCodeGenerationConfig codeGenerationConfig ) {
public static String getDataType( final Optional<Type> dataType, final ImportTracker importTracker,
final JavaCodeGenerationConfig codeGenerationConfig ) {
return dataType.map( type -> {
final Type actualDataType = dataType.get();
if ( actualDataType instanceof ComplexType ) {
final String complexDataType = ((ComplexType) actualDataType).getName();
if ( ( !codeGenerationConfig.namePrefix().isBlank() || !codeGenerationConfig.namePostfix().isBlank() ) ) {
if ( (!codeGenerationConfig.namePrefix().isBlank() || !codeGenerationConfig.namePostfix().isBlank()) ) {
return codeGenerationConfig.namePrefix() + complexDataType + codeGenerationConfig.namePostfix();
}
return complexDataType;
Expand Down Expand Up @@ -491,7 +496,8 @@ public static String generateFilterCompare( final Optional<Type> optionalDataTyp
public static String getCharacteristicJavaType( final Property property, final JavaCodeGenerationConfig codeGenerationConfig ) {
final Supplier<RuntimeException> error = () -> new CodeGenerationException( "No data type found for Property " + property.getName() );
if ( hasContainerType( property ) ) {
return getDataType( property.getCharacteristic().orElseThrow( error ).getDataType(), codeGenerationConfig.importTracker(), codeGenerationConfig );
return getDataType( property.getCharacteristic().orElseThrow( error ).getDataType(), codeGenerationConfig.importTracker(),
codeGenerationConfig );
}

return property.getEffectiveCharacteristic().flatMap( Characteristic::getDataType ).map( type -> {
Expand Down Expand Up @@ -564,7 +570,7 @@ public static String genericClassSignature( final StructureElement element ) {
}

public static String generateClassName( final StructureElement element, final JavaCodeGenerationConfig config ) {
if ( ( !config.namePrefix().isBlank() || !config.namePostfix().isBlank() ) && element.is( StructureElement.class ) ) {
if ( (!config.namePrefix().isBlank() || !config.namePostfix().isBlank()) && element.is( StructureElement.class ) ) {
return config.namePrefix() + element.getName() + config.namePostfix();
}
return element.getName();
Expand Down

0 comments on commit 0d1f312

Please sign in to comment.