From d78072a60e71bc9900e3456f26049b4a9024c989 Mon Sep 17 00:00:00 2001 From: Javatar81 Date: Fri, 30 Aug 2024 14:07:03 +0200 Subject: [PATCH] Fixed format violations --- .../java/generator/CRGeneratorRunner.java | 45 ++++++++++--------- .../java/generator/nodes/JCRObject.java | 21 +++++---- .../fabric8/java/generator/nodes/JObject.java | 10 ++--- .../kubernetes/client/CustomResource.java | 1 - 4 files changed, 38 insertions(+), 39 deletions(-) diff --git a/java-generator/core/src/main/java/io/fabric8/java/generator/CRGeneratorRunner.java b/java-generator/core/src/main/java/io/fabric8/java/generator/CRGeneratorRunner.java index 8ad8dbad6b0..3d8fa4f1203 100644 --- a/java-generator/core/src/main/java/io/fabric8/java/generator/CRGeneratorRunner.java +++ b/java-generator/core/src/main/java/io/fabric8/java/generator/CRGeneratorRunner.java @@ -15,6 +15,15 @@ */ package io.fabric8.java.generator; +import io.fabric8.java.generator.exceptions.JavaGeneratorException; +import io.fabric8.java.generator.nodes.AbstractJSONSchema2Pojo; +import io.fabric8.java.generator.nodes.GeneratorResult; +import io.fabric8.java.generator.nodes.JCRObject; +import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition; +import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionSpec; +import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionVersion; +import io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -25,20 +34,11 @@ import java.util.Optional; import java.util.stream.Collectors; -import io.fabric8.java.generator.exceptions.JavaGeneratorException; -import io.fabric8.java.generator.nodes.AbstractJSONSchema2Pojo; -import io.fabric8.java.generator.nodes.GeneratorResult; -import io.fabric8.java.generator.nodes.JCRObject; -import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition; -import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionSpec; -import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionVersion; -import io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps; - public class CRGeneratorRunner { private final Config config; private static final List STD_PROPS = Arrays.asList("metadata", "spec", "status", "apiVersion", "kind"); - + public CRGeneratorRunner(Config config) { this.config = config; } @@ -54,14 +54,14 @@ public List generate(CustomResourceDefinition crd, St String version = crdv.getName(); String pkgNotOverridden = Optional.ofNullable(basePackageName) - .map(p -> p + "." + version) - .orElse(version); + .map(p -> p + "." + version) + .orElse(version); String pkg; if (config.getPackageOverrides().containsKey(pkgNotOverridden)) { - pkg = config.getPackageOverrides().get(pkgNotOverridden); + pkg = config.getPackageOverrides().get(pkgNotOverridden); } else { - pkg = pkgNotOverridden; + pkg = pkgNotOverridden; } AbstractJSONSchema2Pojo specGenerator = null; @@ -79,16 +79,17 @@ public List generate(CustomResourceDefinition crd, St crName + "Status", status, pkg, config); } - boolean preserveUnknownFields = Boolean.TRUE.equals(crdv.getSchema().getOpenAPIV3Schema().getXKubernetesPreserveUnknownFields()); - + boolean preserveUnknownFields = Boolean.TRUE + .equals(crdv.getSchema().getOpenAPIV3Schema().getXKubernetesPreserveUnknownFields()); + Map topLevelProps = crdv.getSchema().getOpenAPIV3Schema().getProperties().entrySet().stream() - .filter(e -> !STD_PROPS.contains(e.getKey())) - .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); + .filter(e -> !STD_PROPS.contains(e.getKey())) + .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); List requiredTopLevelProps = crdv.getSchema().getOpenAPIV3Schema().getRequired().stream() - .filter(prop -> !STD_PROPS.contains(prop)) - .collect(Collectors.toList()); - + .filter(prop -> !STD_PROPS.contains(prop)) + .collect(Collectors.toList()); + AbstractJSONSchema2Pojo crGenerator = new JCRObject( pkg, crName, @@ -116,7 +117,7 @@ public List generate(CustomResourceDefinition crd, St return writableCUs; } - + private List validateAndAggregate( AbstractJSONSchema2Pojo... generators) { return Arrays.stream(generators) diff --git a/java-generator/core/src/main/java/io/fabric8/java/generator/nodes/JCRObject.java b/java-generator/core/src/main/java/io/fabric8/java/generator/nodes/JCRObject.java index 1a9bac6d55e..14f5b58aa16 100644 --- a/java-generator/core/src/main/java/io/fabric8/java/generator/nodes/JCRObject.java +++ b/java-generator/core/src/main/java/io/fabric8/java/generator/nodes/JCRObject.java @@ -15,11 +15,6 @@ */ package io.fabric8.java.generator.nodes; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.PackageDeclaration; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; @@ -28,10 +23,14 @@ import com.github.javaparser.ast.expr.SingleMemberAnnotationExpr; import com.github.javaparser.ast.expr.StringLiteralExpr; import com.github.javaparser.ast.type.ClassOrInterfaceType; - import io.fabric8.java.generator.Config; import io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + public class JCRObject extends JObject implements JObjectExtraAnnotations { private final String group; @@ -67,7 +66,7 @@ public JCRObject( String plural, Config config) { - super(pkg, type, toplevelProps, required, preserveUnknownFields, config, description, false, null); + super(pkg, type, toplevelProps, required, preserveUnknownFields, config, description, false, null); this.group = group; this.version = version; @@ -123,7 +122,7 @@ public GeneratorResult generateJava() { new Name("io.fabric8.kubernetes.model.annotation.Plural"), new StringLiteralExpr(plural))); } - + ClassOrInterfaceType jlVoid = new ClassOrInterfaceType().setName("java.lang.Void"); ClassOrInterfaceType spec = (withSpec) @@ -150,10 +149,10 @@ public GeneratorResult generateJava() { if (config.isObjectExtraAnnotations()) { addExtraAnnotations(clz); } - + List buffer = generateJavaFields(clz); - - List results = new ArrayList<>(); + + List results = new ArrayList<>(); results.add(new GeneratorResult.ClassResult(className, cu)); results.addAll(buffer); return new GeneratorResult( diff --git a/java-generator/core/src/main/java/io/fabric8/java/generator/nodes/JObject.java b/java-generator/core/src/main/java/io/fabric8/java/generator/nodes/JObject.java index 84c57c60f48..b2aa43350bd 100644 --- a/java-generator/core/src/main/java/io/fabric8/java/generator/nodes/JObject.java +++ b/java-generator/core/src/main/java/io/fabric8/java/generator/nodes/JObject.java @@ -195,10 +195,10 @@ public GeneratorResult generateJava() { return new GeneratorResult(buffer); } -protected List generateJavaFields(ClassOrInterfaceDeclaration clz) { - List buffer = new ArrayList<>(this.fields.size() + 1); - - List sortedKeys = this.fields.keySet().stream().sorted().collect(Collectors.toList()); + protected List generateJavaFields(ClassOrInterfaceDeclaration clz) { + List buffer = new ArrayList<>(this.fields.size() + 1); + + List sortedKeys = this.fields.keySet().stream().sorted().collect(Collectors.toList()); for (String k : sortedKeys) { AbstractJSONSchema2Pojo prop = this.fields.get(k); boolean isRequired = this.required.contains(k); @@ -351,7 +351,7 @@ protected List generateJavaFields(ClassOrInterfaceD .setBody(new BlockStmt().addStatement(new NameExpr("this." + Keywords.ADDITIONAL_PROPERTIES + ".put(key, value)"))); } return buffer; -} + } /** * This method is responsible for creating an expression that will initialize the default value if primitive diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/CustomResource.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/CustomResource.java index fca65c14fad..0e1729c72e9 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/CustomResource.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/CustomResource.java @@ -19,7 +19,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonProperty.Access; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.annotation.JsonDeserialize;