Class DefaultDummyFactory

java.lang.Object
de.yamass.redg.runtime.dummy.DefaultDummyFactory
All Implemented Interfaces:
DummyFactory

public class DefaultDummyFactory extends Object implements 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 Details

    • DefaultDummyFactory

      public DefaultDummyFactory()
  • Method Details

    • getDummy

      public <T extends RedGEntity> T getDummy(AbstractRedG redG, Class<T> dummyClass)
      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 interface DummyFactory
      Type Parameters:
      T - The wanted entity type
      Parameters:
      redG - The redG instance
      dummyClass - 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

      public boolean isDummy(RedGEntity entity)
      Checks whether an entity is a dummy generated by this dummy factory by comparing it against the internal dummy cache.
      Specified by:
      isDummy in interface DummyFactory
      Parameters:
      entity - The entity to check
      Returns:
      true if the entity is a dummy entity, false otherwise