Skip to content

Commit

Permalink
correct style with curly braces
Browse files Browse the repository at this point in the history
  • Loading branch information
sv99 committed Jul 24, 2023
1 parent a86a40f commit 7b09b5e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ public static String unescape(String value) {
}

public String getValue() {
if (value.equals("null"))
if (value.equals("null")) {
return null;
}
String res = unescape(value);
// remove quotation marks
res = res.replaceAll("^\"|\"$", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public YamlReader(InputStream in) {
}

public void pushLine() {
if (mCurrent > 0)
if (mCurrent > 0) {
mCurrent--;
}
}

public void read(InputStream in) {
Expand Down Expand Up @@ -48,22 +49,26 @@ public boolean isCommentOrEmpty() {
}

public void skipInsignificant() {
if (isEnd())
if (isEnd()) {
return;
}
while (isCommentOrEmpty()) {
mCurrent++;
if (isEnd())
if (isEnd()) {
break;
}
}
}

public boolean nextLine() {
if (isEnd())
if (isEnd()) {
return false;
}
while (true) {
mCurrent++;
if (isCommentOrEmpty())
if (isCommentOrEmpty()) {
continue;
}
return !isEnd();
}
}
Expand All @@ -80,13 +85,15 @@ interface Updater<T> {
* Read root object from start to end
*/
public <T extends YamlSerializable> void readRoot(T obj) throws AndrolibException {
if (isEnd())
if (isEnd()) {
return;
}
int objIndent = 0;
skipInsignificant();
while (true) {
if (isEnd())
if (isEnd()) {
return;
}
YamlLine line = getLine();
// skip don't checked line or lines with other indent
if (objIndent != line.indent || !line.hasColon) {
Expand All @@ -106,8 +113,9 @@ public <T extends YamlSerializable> void readRoot(T obj) throws AndrolibExceptio
public <T> void readObject(T obj,
Checker check,
Updater<T> updater) throws AndrolibException {
if (isEnd())
if (isEnd()) {
return;
}
int prevIndent = getIndent();
// detect indent for the object data
nextLine();
Expand All @@ -121,8 +129,9 @@ public <T> void readObject(T obj,
}
updater.update(obj, this);
while (nextLine()) {
if (isEnd())
if (isEnd()) {
return;
}
line = getLine();
if (objIndent != line.indent || !check.check(line)) {
pushLine();
Expand All @@ -145,14 +154,16 @@ <T extends YamlSerializable> void readObject(T obj) throws AndrolibException {
*/
public <T> void readList(List<T> list,
Updater<List<T>> updater) throws AndrolibException {
if (isEnd())
if (isEnd()) {
return;
}
int listIndent = getIndent();
nextLine();
int dataIndent = getIndent();
while (true) {
if (isEnd())
if (isEnd()) {
return;
}
// check incorrect data indent
if (dataIndent < listIndent) {
pushLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ public void nextIndent() {
}

public void prevIndent() {
if (mIndent != 0)
if (mIndent != 0) {
mIndent -= 2;
}
}

public void writeIndent() {
Expand All @@ -55,8 +56,9 @@ public void writeString(String key, String value, boolean quoted) {
if (Objects.isNull(value)) {
mWriter.println(escape(key) + ": null");
} else {
if (quoted)
if (quoted) {
value = QUOTE + value + QUOTE;
}
mWriter.println(escape(key) + ": " + escape(value));
}
}
Expand All @@ -66,8 +68,9 @@ public void writeString(String key, String value) {
}

public <T> void writeList(String key, List<T> list) {
if (Objects.isNull(list))
if (Objects.isNull(list)) {
return;
}
writeIndent();
mWriter.println(escape(key) + ":");
for (T item: list) {
Expand All @@ -77,8 +80,9 @@ public <T> void writeList(String key, List<T> list) {
}

public void writeStringMap(String key, Map<String, String> map) {
if (Objects.isNull(map))
if (Objects.isNull(map)) {
return;
}
writeIndent();
mWriter.println(escape(key) + ":");
nextIndent();
Expand All @@ -89,8 +93,9 @@ public void writeStringMap(String key, Map<String, String> map) {
}

public <T extends YamlSerializable> void writeObject(String key, T obj) {
if (Objects.isNull(obj))
if (Objects.isNull(obj)) {
return;
}
writeIndent();
mWriter.println(escape(key) + ":");
nextIndent();
Expand Down

0 comments on commit 7b09b5e

Please sign in to comment.