@Test public void testConstraintWalkOrder() { Archetype archetype = parseArchetype("adl15/walker/adl-test-entry.walk_order.v1.adls"); final ConstraintListVisitor listVisitor = new ConstraintListVisitor(); AmVisitor<AmObject, AmConstraintContext> visitor = new ConstraintAmVisitor<>() .add(AmObject.class, listVisitor); ArchetypeWalker.walkConstraints(visitor, archetype, new AmConstraintContext()); assertThat(listVisitor.visits).containsExactly( "C::ENTRY", "A:/items:items", "C:/items[at10001]:ELEMENT", "A:/items[at10001]/value:value", "C:/items[at10001]/value:DV_ORDINAL", "C:/items[at10003]:ELEMENT", "A:/items[at10003]/value:value", "C:/items[at10003]/value:DV_ORDINAL"); }
@SuppressWarnings("unchecked") public static <T extends AmObject, C extends AmConstraintContext> void walkConstraints(AmVisitor<T, C> visitor, Archetype archetype, C context) { if (!(visitor instanceof ConstraintAmVisitor<?>)) { visitor = new ConstraintAmVisitor<>().add(AmObject.class, (AmVisitor) visitor); } ArchetypeWalker<C> walker = new ArchetypeWalker<>((AmVisitor<AmObject, C>) visitor, context); Action<?> action = walker.walk(archetype.getDefinition()); if (action.act != Action.Act.next) { throw new AssertionError("Cannot remove or replace root constraint"); } }
ArchetypeWalker { @SuppressWarnings("unchecked") public static <T extends AmObject, C extends AmConstraintContext> void walkConstraints(AmVisitor<T, C> visitor, Archetype archetype, C context) { if (!(visitor instanceof ConstraintAmVisitor<?>)) { visitor = new ConstraintAmVisitor<>().add(AmObject.class, (AmVisitor) visitor); } ArchetypeWalker<C> walker = new ArchetypeWalker<>((AmVisitor<AmObject, C>) visitor, context); Action<?> action = walker.walk(archetype.getDefinition()); if (action.act != Action.Act.next) { throw new AssertionError("Cannot remove or replace root constraint"); } } }
ArchetypeWalker { @SuppressWarnings("unchecked") public static <T extends AmObject, C extends AmConstraintContext> void walkConstraints(AmVisitor<T, C> visitor, Archetype archetype, C context) { if (!(visitor instanceof ConstraintAmVisitor<?>)) { visitor = new ConstraintAmVisitor<>().add(AmObject.class, (AmVisitor) visitor); } ArchetypeWalker<C> walker = new ArchetypeWalker<>((AmVisitor<AmObject, C>) visitor, context); Action<?> action = walker.walk(archetype.getDefinition()); if (action.act != Action.Act.next) { throw new AssertionError("Cannot remove or replace root constraint"); } } private  ArchetypeWalker(AmVisitor<AmObject, C> visitor, C context); }
ArchetypeWalker { @SuppressWarnings("unchecked") public static <T extends AmObject, C extends AmConstraintContext> void walkConstraints(AmVisitor<T, C> visitor, Archetype archetype, C context) { if (!(visitor instanceof ConstraintAmVisitor<?>)) { visitor = new ConstraintAmVisitor<>().add(AmObject.class, (AmVisitor) visitor); } ArchetypeWalker<C> walker = new ArchetypeWalker<>((AmVisitor<AmObject, C>) visitor, context); Action<?> action = walker.walk(archetype.getDefinition()); if (action.act != Action.Act.next) { throw new AssertionError("Cannot remove or replace root constraint"); } } private  ArchetypeWalker(AmVisitor<AmObject, C> visitor, C context); @SuppressWarnings("unchecked") static void walkConstraints(AmVisitor<T, C> visitor, Archetype archetype,
            C context); static void walkTerminology(AmVisitor<AmObject, C> visitor, ArchetypeTerminology terminology, C context); }
ArchetypeWalker { @SuppressWarnings("unchecked") public static <T extends AmObject, C extends AmConstraintContext> void walkConstraints(AmVisitor<T, C> visitor, Archetype archetype, C context) { if (!(visitor instanceof ConstraintAmVisitor<?>)) { visitor = new ConstraintAmVisitor<>().add(AmObject.class, (AmVisitor) visitor); } ArchetypeWalker<C> walker = new ArchetypeWalker<>((AmVisitor<AmObject, C>) visitor, context); Action<?> action = walker.walk(archetype.getDefinition()); if (action.act != Action.Act.next) { throw new AssertionError("Cannot remove or replace root constraint"); } } private  ArchetypeWalker(AmVisitor<AmObject, C> visitor, C context); @SuppressWarnings("unchecked") static void walkConstraints(AmVisitor<T, C> visitor, Archetype archetype,
            C context); static void walkTerminology(AmVisitor<AmObject, C> visitor, ArchetypeTerminology terminology, C context);  }