Use consistent method names.

This commit is contained in:
Michael Lipp 2025-01-25 13:39:22 +01:00
parent 5d722abd2e
commit 2a70c74234
3 changed files with 12 additions and 12 deletions

View file

@ -86,14 +86,14 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
// Maybe override logging.properties from reconciler configuration.
DataPath.<String> get(model, "reconciler", "loggingProperties")
.ifPresent(props -> {
GsonPtr.to(mapDef.getRaw()).get(JsonObject.class, "data")
GsonPtr.to(mapDef.getRaw()).getAs(JsonObject.class, "data")
.get().addProperty("logging.properties", props);
});
// Maybe override logging.properties from VM definition.
DataPath.<String> get(model, "cr", "spec", "loggingProperties")
.ifPresent(props -> {
GsonPtr.to(mapDef.getRaw()).get(JsonObject.class, "data")
GsonPtr.to(mapDef.getRaw()).getAs(JsonObject.class, "data")
.get().addProperty("logging.properties", props);
});

View file

@ -204,7 +204,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
// If bound, use json merge, omitting immutable fields
var spec = GsonPtr.to(pvcDef.getRaw()).to("spec");
spec.removeExcept("volumeAttributesClassName", "resources");
spec.access("resources").ifPresent(p -> p.removeExcept("requests"));
spec.get("resources").ifPresent(p -> p.removeExcept("requests"));
PatchOptions opts = new PatchOptions();
opts.setFieldManager("kubernetes-java-kubectl-apply");
if (pvcStub.patch(V1Patch.PATCH_FORMAT_JSON_MERGE_PATCH,

View file

@ -103,7 +103,7 @@ public class GsonPtr {
* @return the Gson pointer
*/
@SuppressWarnings({ "PMD.ShortMethodName", "PMD.PreserveStackTrace" })
public Optional<GsonPtr> access(Object... selectors) {
public Optional<GsonPtr> get(Object... selectors) {
JsonElement element = position;
for (Object sel : selectors) {
if (element instanceof JsonObject obj
@ -147,7 +147,7 @@ public class GsonPtr {
* @return the result
*/
@SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop" })
public <T extends JsonElement> T get(Class<T> cls) {
public <T extends JsonElement> T getAs(Class<T> cls) {
if (cls.isAssignableFrom(position.getClass())) {
return cls.cast(position);
}
@ -166,7 +166,7 @@ public class GsonPtr {
*/
@SuppressWarnings({ "PMD.AvoidBranchingStatementAsLastInLoop" })
public <T extends JsonElement> Optional<T>
get(Class<T> cls, Object... selectors) {
getAs(Class<T> cls, Object... selectors) {
JsonElement element = position;
for (Object sel : selectors) {
if (element instanceof JsonObject obj
@ -201,7 +201,7 @@ public class GsonPtr {
* @return the as string
*/
public Optional<String> getAsString(Object... selectors) {
return get(JsonPrimitive.class, selectors)
return getAs(JsonPrimitive.class, selectors)
.map(JsonPrimitive::getAsString);
}
@ -212,7 +212,7 @@ public class GsonPtr {
* @return the as string
*/
public Optional<Integer> getAsInt(Object... selectors) {
return get(JsonPrimitive.class, selectors)
return getAs(JsonPrimitive.class, selectors)
.map(JsonPrimitive::getAsInt);
}
@ -223,7 +223,7 @@ public class GsonPtr {
* @return the as string
*/
public Optional<BigInteger> getAsBigInteger(Object... selectors) {
return get(JsonPrimitive.class, selectors)
return getAs(JsonPrimitive.class, selectors)
.map(JsonPrimitive::getAsBigInteger);
}
@ -234,7 +234,7 @@ public class GsonPtr {
* @return the as string
*/
public Optional<Long> getAsLong(Object... selectors) {
return get(JsonPrimitive.class, selectors)
return getAs(JsonPrimitive.class, selectors)
.map(JsonPrimitive::getAsLong);
}
@ -245,7 +245,7 @@ public class GsonPtr {
* @return the boolean
*/
public Optional<Boolean> getAsBoolean(Object... selectors) {
return get(JsonPrimitive.class, selectors)
return getAs(JsonPrimitive.class, selectors)
.map(JsonPrimitive::getAsBoolean);
}
@ -260,7 +260,7 @@ public class GsonPtr {
@SuppressWarnings("unchecked")
public <T extends JsonElement> List<T> getAsListOf(Class<T> cls,
Object... selectors) {
return get(JsonArray.class, selectors).map(a -> (List<T>) a.asList())
return getAs(JsonArray.class, selectors).map(a -> (List<T>) a.asList())
.orElse(Collections.emptyList());
}