Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
Avoid redundancy: call tail(path) once, add else block (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Sep 25, 2024
1 parent fffb6d9 commit 629a9d6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions metafix/src/main/java/org/metafacture/metafix/FixPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,15 @@ else if (isReference(field)) {
}
else {
if (!hash.containsField(field)) {
if (ReservedField.$prepend.name().equals(tail(path)[0]) || ReservedField.$append.name().equals(tail(path)[0])) {
hash.put(field, Value.newArray().withPathSet(newValue.getPath()));
}
else {
hash.put(field, Value.newHash().withPathSet(newValue.getPath()));
}
final Value value = Arrays.asList(ReservedField.$prepend.name(), ReservedField.$append.name())
.contains(tail(path)[0]) ? Value.newArray() : Value.newHash();
hash.put(field, value.withPathSet(newValue.getPath()));
}
final Value value = hash.get(field);
if (value.isString()) {
hash.put(field, Value.newArray(a -> a.add(value)));
else {
final Value value = hash.get(field);
if (value.isString()) {
hash.put(field, Value.newArray(a -> a.add(value)));
}
}
insertInto(hash.get(field), mode, newValue, field, tail(path));
}
Expand Down

0 comments on commit 629a9d6

Please sign in to comment.