Package cz.o2.proxima.core.repository
Class Repository
- java.lang.Object
-
- cz.o2.proxima.core.repository.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Repository.Validate
Various validation flags.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addedDataOperator(DataOperator op)
Called when newDataOperator
is created.RepositoryFactory
asFactory()
Convert this repository toSerializable
factory.abstract void
drop()
Drop theRepository
and let it recreate from scratch using factory.abstract java.util.Optional<EntityDescriptor>
findEntity(java.lang.String name)
Find entity descriptor based on entity name.abstract java.util.Optional<AttributeFamilyDescriptor>
findFamilyByName(java.lang.String name)
Retrieve attribute family by name.abstract java.util.stream.Stream<EntityDescriptor>
getAllEntities()
Retrieve stream of all entities.java.util.stream.Stream<AttributeFamilyDescriptor>
getAllFamilies()
List all unique attribute families.abstract java.util.stream.Stream<AttributeFamilyDescriptor>
getAllFamilies(boolean includeSystem)
List all unique attribute families, possibly including system attribute families.EntityDescriptor
getEntity(java.lang.String name)
Get entity descriptor based on entity name.abstract java.util.Set<AttributeFamilyDescriptor>
getFamiliesForAttribute(AttributeDescriptor<?> attr)
Retrieve list of attribute families for attribute.AttributeFamilyDescriptor
getFamilyByName(java.lang.String name)
Retrieve attribute family by name.<T extends DataOperator>
TgetOrCreateOperator(java.lang.Class<T> type, Consumer<T>... modifiers)
Retrieve instance of data operator or create new instance with given settings.abstract java.util.Map<java.lang.String,TransformationDescriptor>
getTransformations()
Retrieve all transformers.abstract java.util.Optional<ValueSerializerFactory>
getValueSerializerFactory(java.lang.String scheme)
Retrieve value serializer for given scheme.boolean
hasOperator(java.lang.String name)
Check if given implementation of data operator is available on classpath andgetOrCreateOperator(Class, Consumer[])
(java.lang.Class, Consumer...)} will return non-null object for class corresponding the given name.abstract boolean
isEmpty()
Check if this repository is empty.abstract boolean
isShouldValidate(Repository.Validate what)
Check if thisRepository
should eagerly validate various settings.static Repository
of(cz.o2.proxima.typesafe.config.Config config)
CreateRepository
from givenConfig
.static Repository
ofTest(cz.o2.proxima.typesafe.config.Config config, Repository.Validate... validate)
CreateRepository
from givenConfig
for testing purposes.
-
-
-
Method Detail
-
of
public static Repository of(cz.o2.proxima.typesafe.config.Config config)
CreateRepository
from givenConfig
.- Parameters:
config
- the config- Returns:
- repository
-
ofTest
public static Repository ofTest(cz.o2.proxima.typesafe.config.Config config, Repository.Validate... validate)
CreateRepository
from givenConfig
for testing purposes.- Parameters:
config
- the configvalidate
- validations that should be performed- Returns:
- repository
-
asFactory
public RepositoryFactory asFactory()
Convert this repository toSerializable
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
-
getValueSerializerFactory
public abstract java.util.Optional<ValueSerializerFactory> getValueSerializerFactory(java.lang.String scheme)
Retrieve value serializer for given scheme.- Parameters:
scheme
- scheme of theValueSerializerFactory
- Returns:
- optional
ValueSerializerFactory
for the scheme
-
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 classmodifiers
- 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 andgetOrCreateOperator(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 thisRepository
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 theRepository
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 newDataOperator
is created.- Parameters:
op
- the operator that was created
-
-