Skip to content

Commit

Permalink
new nesting label
Browse files Browse the repository at this point in the history
  • Loading branch information
KrLite committed May 2, 2024
1 parent 8c0c081 commit 40a6bf2
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions src/main/java/band/kessokuteatime/nightautoconfig/spec/Specs.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,27 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Predicate;
import java.util.stream.Stream;

public record Specs<T>(T t, ConfigType type, String fileName) {
public enum Session {
SAVING("Saving"),
NESTED_SAVING("Saving/Nested"),
LOADING("Loading"),
NESTED_LOADING("Loading/Nested"),
UNKNOWN("Unknown");
public record Session(Type type, int layer) {
public enum Type {
SAVING, LOADING;
}

private final String name;
public static final Session SAVING = new Session(Type.SAVING, 0);

Session(String name) {
this.name = name;
}
public static final Session LOADING = new Session(Type.LOADING, 0);

public String semanticName() {
return name;
public Session nested() {
return new Session(type, layer + 1);
}

public Session nested() {
return switch (this) {
case SAVING, NESTED_SAVING -> NESTED_SAVING;
case LOADING, NESTED_LOADING -> NESTED_LOADING;
default -> UNKNOWN;
};
@Override
public String toString() {
return layer == 0
? type().name()
: String.format("%s -> NESTED BY %d", type().name(), layer);
}
}

Expand Down Expand Up @@ -154,7 +150,7 @@ static boolean isNested(Field field) {
}

private String loggerPrefix(Session session) {
return String.format("[%s](%s)", fileName, session.semanticName());
return String.format("[%s](%s)", fileName, session);
}

private Field[] fields() {
Expand Down

0 comments on commit 40a6bf2

Please sign in to comment.