@Override public String getCanonicalString(final Context context) { final Class<?> targetType = context.getLiteralizableTargetType(o.getClass()); return SnapshotMaker.makeSnapshotAsSubclass(o, targetType, targetType, null).generate(context); } };
final MetaClass ... typesToRecurseOn) { return makeSnapshotAsSubclass( o, typeToSnapshot,
@Override public String getCanonicalString(final Context context) { final Class<?> targetType = context.getLiteralizableTargetType(o.getClass()); return SnapshotMaker.makeSnapshotAsSubclass(o, targetType, targetType, null).generate(context); } };
final MetaClass ... typesToRecurseOn) { return makeSnapshotAsSubclass( o, typeToSnapshot,
metaTypesToRecurseOn[i] = MetaClassFactory.get(typesToRecurseOn[i]); return makeSnapshotAsSubclass(o, metaTypeToSnapshot, metaTypeToExtend, methodBodyCallback, metaTypesToRecurseOn);
metaTypesToRecurseOn[i] = MetaClassFactory.get(typesToRecurseOn[i]); return makeSnapshotAsSubclass(o, metaTypeToSnapshot, metaTypeToExtend, methodBodyCallback, metaTypesToRecurseOn);
@Test public void testNoStackOverflowOnObjectCycle() { PersonImpl cycle1 = new PersonImpl("cycle1", 30, null); Person cycle2 = new PersonImpl("cycle2", 5, cycle1); cycle1.setMother(cycle2); try { Statement snapshotStmt = SnapshotMaker.makeSnapshotAsSubclass(cycle2, Person.class, Person.class, null, Person.class); snapshotStmt.generate(Context.create()); Assert.fail("Instance cycle was not detected"); } catch (CyclicalObjectGraphException e) { assertTrue(e.getObjectsInvolvedInCycle().contains(cycle1)); assertTrue(e.getObjectsInvolvedInCycle().contains(cycle2)); } }
Statement attribSnapshot = SnapshotMaker.makeSnapshotAsSubclass( attrib, SingularAttribute.class, ErraiSingularAttribute.class, methodBodyCallback, EntityType.class, ManagedType.class, Type.class); Statement attribSnapshot = SnapshotMaker.makeSnapshotAsSubclass( attrib, PluralAttribute.class, ErraiPluralAttribute.class, methodBodyCallback, EntityType.class, ManagedType.class, Type.class);
Person mother = new PersonImpl("mom", 30, null); Person child = new PersonImpl("kid", 5, mother); Statement snapshotStmt = SnapshotMaker.makeSnapshotAsSubclass(child, Person.class, Person.class, null, Person.class);
.asFinal() .named("mom") .initializeWith(SnapshotMaker.makeSnapshotAsSubclass(mom, Person.class, Person.class, null, Person.class)); method.append(momVar); method.append(Stmt.declareVariable("kid1", SnapshotMaker.makeSnapshotAsSubclass(kid1, Person.class, Person.class, mbcb, Person.class))); method.append(Stmt.declareVariable("kid2", SnapshotMaker.makeSnapshotAsSubclass(kid2, Person.class, Person.class, mbcb, Person.class))); method.append(Stmt.declareVariable("kid3", SnapshotMaker.makeSnapshotAsSubclass(kid3, Person.class, Person.class, mbcb, Person.class)));