Interface IEntityFactory<E extends IEntity,​S extends IEntity,​B extends IEntityBuilder>

  • Type Parameters:
    E - The type of the entity produced by this factory, i.e. the facade.
    S - The super type of the entity, i.e. the generated super class.
    B - The builder type of the entity.
    All Known Implementing Classes:
    EntityFactory

    public interface IEntityFactory<E extends IEntity,​S extends IEntity,​B extends IEntityBuilder>
    A factory for an enclosing entity type.
    Author:
    Bruce Skingle
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      String getCanonType()
      Return the type identifier (_type JSON attribute) for entities created by this factory.
      com.google.common.collect.ImmutableList<E> newImmutableList​(org.symphonyoss.s2.common.dom.json.JsonArray<?> jsonArray, IModelRegistry modelRegistry)
      Return a list of new entity instances created from the given JSON array.
      com.google.common.collect.ImmutableSet<E> newImmutableSet​(org.symphonyoss.s2.common.dom.json.JsonArray<?> jsonArray, IModelRegistry modelRegistry)
      Return a set of new entity instances created from the given JSON array.
      E newInstance​(B builder)
      Return a new entity instance created from the given other instance.
      E newInstance​(org.symphonyoss.s2.common.dom.json.ImmutableJsonObject jsonObject, IModelRegistry modelRegistry)
      Return a new entity instance created from the given JSON serialization.
      List<E> newMutableList​(org.symphonyoss.s2.common.dom.json.JsonArray<?> jsonArray, IModelRegistry modelRegistry)
      Return a list of new entity instances created from the given JSON array.
      Set<E> newMutableSet​(org.symphonyoss.s2.common.dom.json.JsonArray<?> jsonArray, IModelRegistry modelRegistry)
      Return a set of new entity instances created from the given JSON array.
    • Method Detail

      • getCanonType

        @Nonnull
        String getCanonType()
        Return the type identifier (_type JSON attribute) for entities created by this factory.
        Returns:
        The type identifier for entities created by this factory.
      • newInstance

        E newInstance​(org.symphonyoss.s2.common.dom.json.ImmutableJsonObject jsonObject,
                      IModelRegistry modelRegistry)
        Return a new entity instance created from the given JSON serialization.
        Parameters:
        jsonObject - The JSON serialized form of the required entity.
        modelRegistry - A model registry to use to deserialize any nested objects.
        Returns:
        An instance of the entity represented by the given serialized form.
        Throws:
        IllegalArgumentException - If the given JSON is not valid.
      • newInstance

        E newInstance​(B builder)
        Return a new entity instance created from the given other instance. This is used to construct an entity from its builder as the builder also implements the interface of the entity.
        Parameters:
        builder - a builder containing values of all fields for the required entity.
        Returns:
        An instance of the entity represented by the given values.
        Throws:
        IllegalArgumentException - If the given values are not valid.
      • newMutableList

        List<E> newMutableList​(org.symphonyoss.s2.common.dom.json.JsonArray<?> jsonArray,
                               IModelRegistry modelRegistry)
        Return a list of new entity instances created from the given JSON array.
        Parameters:
        jsonArray - An array of the JSON serialized form of the required entity.
        modelRegistry - A model registry to use to deserialize any nested objects.
        Returns:
        A list of instances of the entity represented by the given serialized form.
        Throws:
        IllegalArgumentException - If the given JSON is not valid.
      • newMutableSet

        Set<E> newMutableSet​(org.symphonyoss.s2.common.dom.json.JsonArray<?> jsonArray,
                             IModelRegistry modelRegistry)
        Return a set of new entity instances created from the given JSON array.
        Parameters:
        jsonArray - An array of the JSON serialized form of the required entity.
        modelRegistry - A model registry to use to deserialize any nested objects.
        Returns:
        A set of instances of the entity represented by the given serialized form.
        Throws:
        IllegalArgumentException - If the given JSON is not valid.
      • newImmutableList

        com.google.common.collect.ImmutableList<E> newImmutableList​(org.symphonyoss.s2.common.dom.json.JsonArray<?> jsonArray,
                                                                    IModelRegistry modelRegistry)
        Return a list of new entity instances created from the given JSON array.
        Parameters:
        jsonArray - An array of the JSON serialized form of the required entity.
        modelRegistry - A model registry to use to deserialize any nested objects.
        Returns:
        A list of instances of the entity represented by the given serialized form.
        Throws:
        IllegalArgumentException - If the given JSON is not valid.
      • newImmutableSet

        com.google.common.collect.ImmutableSet<E> newImmutableSet​(org.symphonyoss.s2.common.dom.json.JsonArray<?> jsonArray,
                                                                  IModelRegistry modelRegistry)
        Return a set of new entity instances created from the given JSON array.
        Parameters:
        jsonArray - An array of the JSON serialized form of the required entity.
        modelRegistry - A model registry to use to deserialize any nested objects.
        Returns:
        A set of instances of the entity represented by the given serialized form.
        Throws:
        IllegalArgumentException - If the given JSON is not valid.