com.relogiclabs.json.schema.internal.util.DebugUtilities Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of relogiclabs-json-schema Show documentation
Show all versions of relogiclabs-json-schema Show documentation
The New JSON Schema prioritizes simplicity, conciseness, and readability, making
it user-friendly and accessible without the need for extensive prior knowledge.
It offers efficient read-write facilities, precise JSON document definition
through various data types and functions, and extensibility to meet modern web
service diverse requirements.
package com.relogiclabs.json.schema.internal.util;
import com.relogiclabs.json.schema.internal.time.DateTimeContext;
import com.relogiclabs.json.schema.tree.DataTree;
import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.Recognizer;
import java.util.Collections;
import java.util.List;
import static com.relogiclabs.json.schema.internal.util.StringHelper.concat;
// External logging library may consider
// Kept it lightweight for now
public final class DebugUtilities {
public static boolean debugPrint = false;
public static void print(DataTree expected, DataTree actual) {
if(!debugPrint) return;
System.out.println(concat("[DEBUG] Expected ", expected.getType(),
" tree interpretation:"));
System.out.println(expected.getRoot());
System.out.println("---");
System.out.println(concat("[DEBUG] Actual ", actual.getType(),
" tree interpretation:"));
System.out.println(actual.getRoot());
System.out.println("---");
}
public static void print(Recognizer, ?> recognizer) {
if(!debugPrint) return;
List stack = ((Parser) recognizer).getRuleInvocationStack();
Collections.reverse(stack);
System.err.println("[DEBUG] Rule stack: " + String.join(" > ", stack));
}
public static void print(DateTimeContext context) {
if(!debugPrint) return;
System.out.println("[DEBUG] Date and time interpretation: " + context);
}
public static void print(Exception e) {
if(!debugPrint) return;
System.err.println("[DEBUG] Print of exception: " + e);
}
}