Skip to content

Commit

Permalink
Non functional Java styling changes (#10808)
Browse files Browse the repository at this point in the history
* Replace explicit <Type> with <>

* Remove redundant toString() calls on String

* Use StandardCharsets.UTF_8 instead "UTF-8" string

* Simpler annotation format and redundant this

* Dont concat on empty String, use String.valueOf()

* Dont run equals on empty String

* Use string.anyMatch instead counting

* Collection add all instead iterating and adding

* Replace string contact with append chain in stringBuilders
  • Loading branch information
agilob committed Nov 9, 2021
1 parent 53d3c9f commit 4d947a1
Show file tree
Hide file tree
Showing 115 changed files with 523 additions and 531 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static CodegenConfig forName(String name) {
try {
return (CodegenConfig) Class.forName(name).getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new GeneratorNotFoundException("Can't load config class with name '".concat(name) + "'\nAvailable:\n" + availableConfigs.toString(), e);
throw new GeneratorNotFoundException("Can't load config class with name '".concat(name) + "'\nAvailable:\n" + availableConfigs, e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public List<CodegenModel> children;

// anyOf, oneOf, allOf
public Set<String> anyOf = new TreeSet<String>();
public Set<String> oneOf = new TreeSet<String>();
public Set<String> allOf = new TreeSet<String>();
public Set<String> anyOf = new TreeSet<>();
public Set<String> oneOf = new TreeSet<>();
public Set<String> allOf = new TreeSet<>();

// The schema name as written in the OpenAPI document.
public String name;
Expand All @@ -66,20 +66,20 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public boolean isAlias; // Is this effectively an alias of another simple type
public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble, isDate, isDateTime, isShort, isUnboundedInteger, isBoolean;
private boolean additionalPropertiesIsAnyType;
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>(); // all properties (without parent's properties)
public List<CodegenProperty> allVars = new ArrayList<CodegenProperty>(); // all properties (with parent's properties)
public List<CodegenProperty> requiredVars = new ArrayList<CodegenProperty>(); // a list of required properties
public List<CodegenProperty> optionalVars = new ArrayList<CodegenProperty>(); // a list of optional properties
public List<CodegenProperty> readOnlyVars = new ArrayList<CodegenProperty>(); // a list of read-only properties
public List<CodegenProperty> readWriteVars = new ArrayList<CodegenProperty>(); // a list of properties for read, write
public List<CodegenProperty> parentVars = new ArrayList<CodegenProperty>();
public List<CodegenProperty> vars = new ArrayList<>(); // all properties (without parent's properties)
public List<CodegenProperty> allVars = new ArrayList<>(); // all properties (with parent's properties)
public List<CodegenProperty> requiredVars = new ArrayList<>(); // a list of required properties
public List<CodegenProperty> optionalVars = new ArrayList<>(); // a list of optional properties
public List<CodegenProperty> readOnlyVars = new ArrayList<>(); // a list of read-only properties
public List<CodegenProperty> readWriteVars = new ArrayList<>(); // a list of properties for read, write
public List<CodegenProperty> parentVars = new ArrayList<>();
public Map<String, Object> allowableValues;

// Sorted sets of required parameters.
public Set<String> mandatory = new TreeSet<String>(); // without parent's required properties
public Set<String> allMandatory = new TreeSet<String>(); // with parent's required properties
public Set<String> mandatory = new TreeSet<>(); // without parent's required properties
public Set<String> allMandatory = new TreeSet<>(); // with parent's required properties

public Set<String> imports = new TreeSet<String>();
public Set<String> imports = new TreeSet<>();
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasValidation;
/**
* Indicates the OAS schema specifies "nullable: true".
Expand All @@ -104,7 +104,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public boolean hasOnlyReadOnly = true; // true if all properties are read-only
public ExternalDocumentation externalDocumentation;

public Map<String, Object> vendorExtensions = new HashMap<String, Object>();
public Map<String, Object> vendorExtensions = new HashMap<>();
private CodegenComposedSchemas composedSchemas;
private boolean hasMultipleTypes = false;

Expand Down Expand Up @@ -320,7 +320,7 @@ public CodegenDiscriminator getDiscriminator() {

public void setDiscriminator(CodegenDiscriminator discriminator) {
this.discriminator = discriminator;
if (discriminator instanceof CodegenDiscriminator && !discriminator.getMappedModels().isEmpty()) {
if (discriminator != null && !discriminator.getMappedModels().isEmpty()) {
this.hasDiscriminatorWithNonEmptyMapping = true;
}
}
Expand Down Expand Up @@ -1067,13 +1067,13 @@ public void removeAllDuplicatedProperty() {

private List<CodegenProperty> removeDuplicatedProperty(List<CodegenProperty> vars) {
// clone the list first
List<CodegenProperty> newList = new ArrayList<CodegenProperty>();
List<CodegenProperty> newList = new ArrayList<>();
for (CodegenProperty cp : vars) {
newList.add(cp.clone());
}

Set<String> propertyNames = new TreeSet<String>();
Set<String> duplicatedNames = new TreeSet<String>();
Set<String> propertyNames = new TreeSet<>();
Set<String> duplicatedNames = new TreeSet<>();

ListIterator<CodegenProperty> iterator = newList.listIterator();
while (iterator.hasNext()) {
Expand Down
Loading

0 comments on commit 4d947a1

Please sign in to comment.