// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class TestCloneable {
    public static class A {
    }
    @Cloneable
    public static class B {
    }
    @Cloneable(mode=CloneableMode.SHALLOW)
    public static class C {
    }
    @Cloneable(mode=CloneableMode.DEEP)
    public static class D {
    }
    public static void test(Object o) {
        String clznam = o.getClass().getName();
        Cloneable cln = o.getClass().getAnnotation(Cloneable.class);
        if(cln == null) {
            System.out.printf("%s : not cloneable\n", clznam);
        } else {
            switch(cln.mode()) {
            case UNKNOWN:
                System.out.printf("%s : cloneable (unknown)\n", clznam);
                break;
            case SHALLOW:
                System.out.printf("%s : cloneable (shallow)\n", clznam);
                break;
            case DEEP:
                System.out.printf("%s : cloneable (deep)\n", clznam);
                break;
            default:
                throw new RuntimeException("Ooops");
            }
        }
    }
    public static void main(String[] args) {
        test(new A());
        test(new B());
        test(new C());
        test(new D());
    }
}
