import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import java.util.function.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.awt.geom.*;
import javax.imageio.*;
import java.math.*;
import java.time.Duration;
import java.text.NumberFormat;
import static x30_pkg.x30_util.DynamicObject;
import java.text.*;
import java.util.TimeZone;
import java.awt.geom.*;
class main {
static class test_structure_skipDefaultValues_X {
final public test_structure_skipDefaultValues_X setX(int x){ return x(x); }
public test_structure_skipDefaultValues_X x(int x) { this.x = x; return this; } final public int getX(){ return x(); }
public int x() { return x; }
int x = 1;
final public test_structure_skipDefaultValues_X setB(boolean b){ return b(b); }
public test_structure_skipDefaultValues_X b(boolean b) { this.b = b; return this; } final public boolean getB(){ return b(); }
public boolean b() { return b; }
boolean b = true;
final public test_structure_skipDefaultValues_X setC(boolean c){ return c(c); }
public test_structure_skipDefaultValues_X c(boolean c) { this.c = c; return this; } final public boolean getC(){ return c(); }
public boolean c() { return c; }
boolean c = false;
final public test_structure_skipDefaultValues_X setL(List l){ return l(l); }
public test_structure_skipDefaultValues_X l(List l) { this.l = l; return this; } final public List getL(){ return l(); }
public List l() { return l; }
List l = ll(1);
final public test_structure_skipDefaultValues_X setS(String s){ return s(s); }
public test_structure_skipDefaultValues_X s(String s) { this.s = s; return this; } final public String getS(){ return s(); }
public String s() { return s; }
String s;
}
static void testCase(String s, Object o) {
structure_Data d = new structure_Data();
d.skipDefaultValues(true);
String x = shortClassName(test_structure_skipDefaultValues_X.class);
s = migrateClassesInStructureText(s, "X", test_structure_skipDefaultValues_X.class);
assertEqualsVerbose(s, structure(o, d));
}
static void test_structure_skipDefaultValues() {
testCase("X", new test_structure_skipDefaultValues_X());
testCase("X(b=f)", new test_structure_skipDefaultValues_X().b(false));
testCase("X(c=t)", new test_structure_skipDefaultValues_X().c(true));
testCase("X(l=null)", new test_structure_skipDefaultValues_X().l(null));
testCase("X(s=\"hello\")", new test_structure_skipDefaultValues_X().s("hello"));
testCase("array{}", new Object[] {});
}
static String b(Object contents, Object... params) {
return tag("b", contents, params);
}
static int l(Object[] a) { return a == null ? 0 : a.length; }
static int l(boolean[] a) { return a == null ? 0 : a.length; }
static int l(byte[] a) { return a == null ? 0 : a.length; }
static int l(short[] a) { return a == null ? 0 : a.length; }
static int l(long[] a) { return a == null ? 0 : a.length; }
static int l(int[] a) { return a == null ? 0 : a.length; }
static int l(float[] a) { return a == null ? 0 : a.length; }
static int l(double[] a) { return a == null ? 0 : a.length; }
static int l(char[] a) { return a == null ? 0 : a.length; }
static int l(Collection c) { return c == null ? 0 : c.size(); }
static int l(Iterator i) { return iteratorCount_int_close(i); } // consumes the iterator && closes it if possible
static int l(Map m) { return m == null ? 0 : m.size(); }
static int l(CharSequence s) { return s == null ? 0 : s.length(); }
static long l(File f) { return f == null ? 0 : f.length(); }
static int l(IMultiMap mm) { return mm == null ? 0 : mm.size(); }
static int l(AppendableChain a) { return a == null ? 0 : a.size; }
static List ll(A... a) {
ArrayList l = new ArrayList(a.length);
if (a != null) for (A x : a) l.add(x);
return l;
}
static String shortClassName(Object o) {
if (o == null) return null;
Class c = o instanceof Class ? (Class) o : o.getClass();
String name = c.getName();
return shortenClassName(name);
}
static String migrateClassesInStructureText(String s, Object... migrations) {
List tok = javaTokForStructure(s);
int n = l(tok);
for (int i = 0; i < l(migrations); i += 2) {
String from = (String) (migrations[i]);
String fromPlusDollar = from + "$";
Object to = migrations[i+1];
String replacement = to instanceof String ? (String) to : dropPrefix("main$", className((Class) to));
int changes = 0;
for (int j = 1; j < n; j += 2) {
String t = tok.get(j);
if (eq(t, from)) {
tok.set(j, replacement);
++changes;
} else if (startsWith(t, fromPlusDollar)) {
tok.set(j, replacement + t.substring(l(from)));
++changes;
}
}
if (changes > 0)
print("migrateClassesInStructureText: Replaced " + n2(changes, "occurrence") + " of " + from + " with " + to);
}
return join(tok);
}
static String migrateClassesInStructureText(String s, Map migrations) {
return migrateClassesInStructureText(s, mapToParams(migrations));
}
static A assertEqualsVerbose(Object x, A y) {
assertEqualsVerbose((String) null, x, y);
return y;
}
// x = expected, y = actual
static A assertEqualsVerbose(String msg, Object x, A y) {
if (!eq(x, y)) {
throw fail((nempty(msg) ? msg + ": " : "") + "expected: "+ x + ", got: " + y);
} else
print("OK" + (empty(msg) ? "" : " " + msg) + ": " + /*sfu*/(x));
return y;
}
static boolean structure_showTiming, structure_checkTokenCount;
static String structure(Object o) {
return structure(o, new structure_Data());
}
static String structure(Object o, structure_Data d) {
StringWriter sw = new StringWriter();
d.out = new PrintWriter(sw);
structure_go(o, d);
String s = str(sw);
if (structure_checkTokenCount) {
print("token count=" + d.n);
assertEquals("token count", l(javaTokC(s)), d.n);
}
return s;
}
static void structure_go(Object o, structure_Data d) {
structure_1(o, d);
while (nempty(d.stack))
popLast(d.stack).run();
}
static void structureToPrintWriter(Object o, PrintWriter out) { structureToPrintWriter(o, out, new structure_Data()); }
static void structureToPrintWriter(Object o, PrintWriter out, structure_Data d) {
d.out = out;
structure_go(o, d);
}
// leave to false, unless unstructure() breaks
static boolean structure_allowShortening = false;
// info on how to serialize objects of a certain class
static class structure_ClassInfo {
Class c;
String shortName;
List fields;
Method customSerializer;
IVF1