package shop.app;

import shop.core.AccountBase;
import shop.core.PackageNeighbour;
import java.lang.reflect.Modifier;

public class AccessMain {
    private static class PrivateNested { }
    protected static class ProtectedNested { }
    static class PackageNested { }
    public static class PublicNested { }

    public static void main(String[] args) throws Exception {
        PackageNeighbour.show();
        new AccountSub().inside(new AccountSub());

        AccountBase plain = new AccountBase();
        System.out.println("world (other package, no inheritance) reads: " + plain.pub);

        System.out.println("-- modifiers as the JVM records them --");
        for (var f : AccountBase.class.getDeclaredFields()) {
            String m = Modifier.toString(f.getModifiers());
            System.out.printf("field %-5s -> '%s'%n", f.getName(), m);
        }
        for (var c : AccessMain.class.getDeclaredClasses()) {
            System.out.printf("nested %-16s -> '%s'%n", c.getSimpleName(), Modifier.toString(c.getModifiers()));
        }
        System.out.println("top-level AccessMain -> '" + Modifier.toString(AccessMain.class.getModifiers()) + "'");
    }
}
