Class Repository

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    ConfigRepository

    @Evolving
    public abstract class Repository
    extends java.lang.Object
    implements java.io.Serializable
    Repository of all entities configured in the system.
    See Also:
    Serialized Form
    • Method Detail

      • of

        public static Repository of​(cz.o2.proxima.typesafe.config.Config config)
        Create Repository from given Config.
        Parameters:
        config - the config
        Returns:
        repository
      • ofTest

        public static Repository ofTest​(cz.o2.proxima.typesafe.config.Config config,
                                        Repository.Validate... validate)
        Create Repository from given Config for testing purposes.
        Parameters:
        config - the config
        validate - validations that should be performed
        Returns:
        repository
      • asFactory

        public RepositoryFactory asFactory()
        Convert this repository to Serializable factory.
        Returns:
        this repository as factory
      • findEntity

        public abstract java.util.Optional<EntityDescriptor> findEntity​(java.lang.String name)
        Find entity descriptor based on entity name.
        Parameters:
        name - name of the entity to search for
        Returns:
        optional EntityDescriptor found by name
      • getEntity

        public EntityDescriptor getEntity​(java.lang.String name)
        Get entity descriptor based on entity name.
        Parameters:
        name - name of the entity to search for
        Returns:
        EntityDescriptor found by name
      • getAllEntities

        public abstract java.util.stream.Stream<EntityDescriptor> getAllEntities()
        Retrieve stream of all entities.
        Returns:
        Stream of all entities specified in this repository
      • getTransformations

        public abstract java.util.Map<java.lang.String,​TransformationDescriptor> getTransformations()
        Retrieve all transformers.
        Returns:
        all transformations by name
      • isEmpty

        public abstract boolean isEmpty()
        Check if this repository is empty.
        Returns:
        true if this repository is empty
      • getAllFamilies

        public java.util.stream.Stream<AttributeFamilyDescriptor> getAllFamilies()
        List all unique attribute families.
        Returns:
        all families specified in this repository
      • getAllFamilies

        public abstract java.util.stream.Stream<AttributeFamilyDescriptor> getAllFamilies​(boolean includeSystem)
        List all unique attribute families, possibly including system attribute families.
        Parameters:
        includeSystem - true if system families should be included
      • findFamilyByName

        public abstract java.util.Optional<AttributeFamilyDescriptor> findFamilyByName​(java.lang.String name)
        Retrieve attribute family by name.

        Note that this searched all families that were specified in configuration. It might include families not listed in getAllFamilies(), because some families might be removed for various reasons (e.g. when proxying attributes).

        Parameters:
        name - name of the family
        Returns:
        Optional AttributeFamilyDescriptor if family exists
      • getFamilyByName

        public AttributeFamilyDescriptor getFamilyByName​(java.lang.String name)
        Retrieve attribute family by name.

        Note that this searched all families that were specified in configuration. It might include families not listed in getAllFamilies(), because some families might be removed for various reasons (e.g. when proxying attributes).

        Parameters:
        name - name of the family
        Returns:
        AttributeFamilyDescriptor if family exists
        Throws:
        java.lang.IllegalArgumentException - when family doesn't exist
      • getFamiliesForAttribute

        public abstract java.util.Set<AttributeFamilyDescriptor> getFamiliesForAttribute​(AttributeDescriptor<?> attr)
        Retrieve list of attribute families for attribute.
        Parameters:
        attr - attribute descriptor
        Returns:
        all families of given attribute
      • getOrCreateOperator

        @SafeVarargs
        public final <T extends DataOperator> T getOrCreateOperator​(java.lang.Class<T> type,
                                                                    Consumer<T>... modifiers)
        Retrieve instance of data operator or create new instance with given settings.
        Type Parameters:
        T - type of operator
        Parameters:
        type - the operator class
        modifiers - modifiers of operator applied when the operator is created
        Returns:
        the data operator of given type
      • hasOperator

        public boolean hasOperator​(java.lang.String name)
        Check if given implementation of data operator is available on classpath and getOrCreateOperator(Class, Consumer[]) (java.lang.Class, Consumer...)} will return non-null object for class corresponding the given name.
        Parameters:
        name - name of the operator
        Returns:
        true if the operator is available, false otherwise
      • isShouldValidate

        public abstract boolean isShouldValidate​(Repository.Validate what)
        Check if this Repository should eagerly validate various settings.
        Parameters:
        what - validation flag
        Returns:
        true if this Repository should validate settings before usage (typically production settings, while test settings can be less strict).
      • drop

        public abstract void drop()
        Drop the Repository and let it recreate from scratch using factory. This is intended for use in tests mostly to prevent influence between two test cases.
      • addedDataOperator

        protected void addedDataOperator​(DataOperator op)
        Called when new DataOperator is created.
        Parameters:
        op - the operator that was created