Class UsedValuesInferenceContext

All Implemented Interfaces:
IEventChannel, IProfile, IProfileLifecycle, InferenceContext, Serializable

public class UsedValuesInferenceContext extends InferenceContextDelegate
InferenceContext wrapper that registers which values have been used.
Since:
9.3
Author:
m.mahabiersing
See Also:
  • Constructor Details

    • UsedValuesInferenceContext

      public UsedValuesInferenceContext(InferenceContext parent)
      Parameters:
      parent - InferenceContext that will be wrapped by this context
  • Method Details

    • addUsedValue

      protected void addUsedValue(ValueReference reference)
    • getUsedValues

      public ValueReference[] getUsedValues()
    • createInstance

      public IEntityInstance createInstance(String entityName)
      Description copied from interface: IProfile
      This method creates a new empty instance for the specified entity type. The name and id of this new instance are generated by the profile itself.
      Specified by:
      createInstance in interface IProfile
      Overrides:
      createInstance in class ProfileDelegate
      Parameters:
      entityName - The name of the entity for which a new instance should be created.
      Returns:
      A new instance for the specified type. Never null.
    • createInstance

      public IEntityInstance createInstance(String entityName, GUID instanceId, String instanceName)
      Description copied from interface: IProfile
      This method creates a new empty instance for the specified entity type. This method may supply either a name or ID which will be used by the profile to determine these values. When ID and instanceName are supplied with null, the behavior of this function is exactly the same as createInstance( String entityName ).
      Specified by:
      createInstance in interface IProfile
      Overrides:
      createInstance in class ProfileDelegate
      Parameters:
      entityName - The name of the entity for which a new instance should be created.
      instanceId - Unique ID of the new instance. When null is supplied, an ID will be generated by the profile.
      instanceName - Unique name of the new instance. when null is supplied a name will be generated by the profile.
      Returns:
      A new instance for the specified type. Never null.
    • deleteInstance

      public void deleteInstance(IEntityInstance instance, boolean autoDetach)
      Description copied from interface: IProfile
      Deletes the given instance, rendering the parameter useless. Please ensure no calls to the parameter IEntityInstance will be done after the deleteInstance.
      Specified by:
      deleteInstance in interface IProfile
      Overrides:
      deleteInstance in class ProfileDelegate
      Parameters:
      instance - IEntityInstance the instance to delete.
      autoDetach - Boolean indicating if references to this instance should automatically be updated.
    • getActiveInstance

      public IEntityInstance getActiveInstance(String entityName)
      Description copied from interface: InferenceContext
      This method returns the active instance for the specified type. When no active instance can be found for the specified type, the type is assumed to be a singleton instance. When this method is invoked for a non singleton type without any active instance, the call to the getSingletonInstance will fail due to a CreateInstanceException.
      Specified by:
      getActiveInstance in interface InferenceContext
      Overrides:
      getActiveInstance in class InferenceContextDelegate
      Parameters:
      entityName - The entity type for which the active instance is requested.
      Returns:
      The instance that is active for the specified type.
    • getAllInstancesForEntity

      public IEntityInstance[] getAllInstancesForEntity(String entityName, boolean includeChildren)
      Description copied from interface: IProfile
      This method returns all existing instances of a certain type in the profile. Even when there are no instances available for a certain type an empty array will be returned.
      Specified by:
      getAllInstancesForEntity in interface IProfile
      Overrides:
      getAllInstancesForEntity in class ProfileDelegate
      Parameters:
      entityName - The entity type for which the instances are requested.
      includeChildren - when this option is passed as true, all child entity-types are also returned.
      Returns:
      An array of instances for the specified type (never null).
    • getInstance

      public IEntityInstance getInstance(EntityValue instance)
      Description copied from interface: IProfile
      This method can be used to lookup an instance based on a reference.
      Specified by:
      getInstance in interface IProfile
      Overrides:
      getInstance in class ProfileDelegate
      Parameters:
      instance - InstanceReference of the instance that should be returned.
      Returns:
      IEntityInstance The entity instance for the specified ID.
    • getInstanceById

      public IEntityInstance getInstanceById(String entityName, GUID instanceId)
      Description copied from interface: IProfile
      This method returns the instance of the specified type for the given instance id. The id of an instance is generated when the instance is created, and can thus only be used within the same session.
      Specified by:
      getInstanceById in interface IProfile
      Overrides:
      getInstanceById in class ProfileDelegate
      Parameters:
      entityName - The name of the entity (type) of which the instance should be.
      instanceId - The (unique) id of the instance.
      Returns:
      IEntityInstance object of the correct type for the specified name.
    • getInstanceByName

      public IEntityInstance getInstanceByName(String entityName, String instanceName)
      Description copied from interface: IProfile
      This method returns an instance of the specified type for the given instance name.
      Specified by:
      getInstanceByName in interface IProfile
      Overrides:
      getInstanceByName in class ProfileDelegate
      Parameters:
      entityName - The name of the entity (type) of which the instance should be.
      instanceName - The name of the instance.
      Returns:
      IEntityInstance object of the correct type for the specified name.
    • getSingletonInstance

      public IEntityInstance getSingletonInstance(String entityName, boolean create)
      Description copied from interface: IProfile

      This method can be used to retrieve the singleton instance from the profile for a specific entity type. Depending on the value of the create parameter that is passed, the behavior of this method differs slightly.

      • When there is a singleton instance present in the profile for the specified type, this method will return that instance regardless the value of create.
      • When no instance is present for the specified type and create is set to true, the singleton instance will be created and returned.
      • When no instance is present for the specified type and create is set to false, an UnknownInstanceException will be thrown.
      When this method is invoked for an entity that has not been specified as a singleton type in the meta-model, this method will throw an exception, as a singleton instance can not exist for entities that allow multiple instances in the profile.
      Specified by:
      getSingletonInstance in interface IProfile
      Overrides:
      getSingletonInstance in class ProfileDelegate
      Parameters:
      entityName - String the Name of the entity
      create - boolean indicating whether the singleton instance should be created in case it does not exist yet.
      Returns:
      IEntityInstance interface pointing to the singleton ('0'th) instance for the specified entity type.