use of org.apache.cayenne.reflect.SingletonFaultFactory in project cayenne by apache.
the class DataObjectDescriptorFactoryIT method testVisitDeclaredProperties_IterationOrder.
@Test
public void testVisitDeclaredProperties_IterationOrder() {
DataObjectDescriptorFactory factory = new DataObjectDescriptorFactory(resolver.getClassDescriptorMap(), new SingletonFaultFactory());
for (ObjEntity e : resolver.getObjEntities()) {
ClassDescriptor descriptor = factory.getDescriptor(e.getName());
final PropertyDescriptor[] lastProcessed = new PropertyDescriptor[1];
PropertyVisitor visitor = new PropertyVisitor() {
public boolean visitToOne(ToOneProperty property) {
assertPropertiesAreInOrder(lastProcessed[0], property);
lastProcessed[0] = property;
return true;
}
public boolean visitToMany(ToManyProperty property) {
assertPropertiesAreInOrder(lastProcessed[0], property);
lastProcessed[0] = property;
return true;
}
public boolean visitAttribute(AttributeProperty property) {
assertPropertiesAreInOrder(lastProcessed[0], property);
lastProcessed[0] = property;
return true;
}
};
descriptor.visitDeclaredProperties(visitor);
}
}
use of org.apache.cayenne.reflect.SingletonFaultFactory in project cayenne by apache.
the class EntityResolver method getClassDescriptorMap.
/**
* Returns an object that compiles and stores {@link ClassDescriptor}
* instances for all entities.
*
* @since 3.0
*/
public ClassDescriptorMap getClassDescriptorMap() {
if (classDescriptorMap == null) {
synchronized (this) {
if (classDescriptorMap == null) {
ClassDescriptorMap classDescriptorMap = new ClassDescriptorMap(this);
FaultFactory faultFactory = new SingletonFaultFactory();
// add factories in reverse of the desired chain order
classDescriptorMap.addFactory(new ValueHolderDescriptorFactory(classDescriptorMap));
classDescriptorMap.addFactory(new DataObjectDescriptorFactory(classDescriptorMap, faultFactory));
// it with entity proxies here.
for (DataMap map : maps) {
for (String entityName : map.getObjEntityMap().keySet()) {
classDescriptorMap.getDescriptor(entityName);
}
}
this.classDescriptorMap = classDescriptorMap;
}
}
}
return classDescriptorMap;
}
use of org.apache.cayenne.reflect.SingletonFaultFactory in project cayenne by apache.
the class DataObjectDescriptorFactoryIT method testVisitProperties_IterationOrder.
@Test
public void testVisitProperties_IterationOrder() {
DataObjectDescriptorFactory factory = new DataObjectDescriptorFactory(resolver.getClassDescriptorMap(), new SingletonFaultFactory());
for (ObjEntity e : resolver.getObjEntities()) {
ClassDescriptor descriptor = factory.getDescriptor(e.getName());
final PropertyDescriptor[] lastProcessed = new PropertyDescriptor[1];
PropertyVisitor visitor = new PropertyVisitor() {
public boolean visitToOne(ToOneProperty property) {
assertPropertiesAreInOrder(lastProcessed[0], property);
lastProcessed[0] = property;
return true;
}
public boolean visitToMany(ToManyProperty property) {
assertPropertiesAreInOrder(lastProcessed[0], property);
lastProcessed[0] = property;
return true;
}
public boolean visitAttribute(AttributeProperty property) {
assertPropertiesAreInOrder(lastProcessed[0], property);
lastProcessed[0] = property;
return true;
}
};
descriptor.visitProperties(visitor);
}
}
use of org.apache.cayenne.reflect.SingletonFaultFactory in project cayenne by apache.
the class DataObjectDescriptorFactory_InheritanceMapsIT method testVisitProperties_IterationOrder.
@Test
public void testVisitProperties_IterationOrder() {
DataObjectDescriptorFactory factory = new DataObjectDescriptorFactory(resolver.getClassDescriptorMap(), new SingletonFaultFactory());
for (ObjEntity e : resolver.getObjEntities()) {
ClassDescriptor descriptor = factory.getDescriptor(e.getName());
final PropertyDescriptor[] lastProcessed = new PropertyDescriptor[1];
PropertyVisitor visitor = new PropertyVisitor() {
public boolean visitToOne(ToOneProperty property) {
DataObjectDescriptorFactoryIT.assertPropertiesAreInOrder(lastProcessed[0], property);
lastProcessed[0] = property;
return true;
}
public boolean visitToMany(ToManyProperty property) {
DataObjectDescriptorFactoryIT.assertPropertiesAreInOrder(lastProcessed[0], property);
lastProcessed[0] = property;
return true;
}
public boolean visitAttribute(AttributeProperty property) {
DataObjectDescriptorFactoryIT.assertPropertiesAreInOrder(lastProcessed[0], property);
lastProcessed[0] = property;
return true;
}
};
descriptor.visitProperties(visitor);
}
}
Aggregations