Package de.yamass.redg.runtime.dummy
Class DefaultDummyFactory
java.lang.Object
de.yamass.redg.runtime.dummy.DefaultDummyFactory
- All Implemented Interfaces:
DummyFactory
RedG's default dummy factory. It should be able to provide a dummy for the most common scenarios. Special use cases
might render this unusable (circulatory references). In these cases, you can write your own
DummyFactory
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends RedGEntity>
TgetDummy
(AbstractRedG redG, Class<T> dummyClass) Returns a dummy entity for the requested type.boolean
isDummy
(RedGEntity entity) Checks whether an entity is a dummy generated by this dummy factory by comparing it against the internal dummy cache.
-
Constructor Details
-
DefaultDummyFactory
public DefaultDummyFactory()
-
-
Method Details
-
getDummy
Returns a dummy entity for the requested type. All this method guarantees is that the returned entity is a valid entity with all non null foreign key relations filled in, it does not guarantee useful or even semantically correct data. The dummy objects get taken either from the list of objects to insert from the redG object or are created on the fly. The results are cached and the same entity will be returned for consecutive calls for an entity of the same type.- Specified by:
getDummy
in interfaceDummyFactory
- Type Parameters:
T
- The wanted entity type- Parameters:
redG
- The redG instancedummyClass
- The class specifying the wanted entity type- Returns:
- a dummy object of thew required type
- Throws:
DummyCreationException
- When a new dummy has to be created but this creation fails
-
isDummy
Checks whether an entity is a dummy generated by this dummy factory by comparing it against the internal dummy cache.- Specified by:
isDummy
in interfaceDummyFactory
- Parameters:
entity
- The entity to check- Returns:
true
if the entity is a dummy entity,false
otherwise
-