Package net.morimekta.providence.util
Class BaseTypeRegistry
- java.lang.Object
-
- net.morimekta.providence.util.BaseTypeRegistry
-
- All Implemented Interfaces:
TypeRegistry,WritableTypeRegistry
- Direct Known Subclasses:
SimpleTypeRegistry
public abstract class BaseTypeRegistry extends java.lang.Object implements WritableTypeRegistry
Registry for declared types referenced in a flat space program context. The registry itself does not have a context per se, as these may reference each other recursively.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseTypeRegistry()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringfinalTypename(java.lang.String typeName, java.lang.String programContext)Get the final typename of the given identifier within the context.PDescriptorProvidergetProvider(java.lang.String name, java.lang.String context, java.util.Map<java.lang.String,java.lang.String> annotations)Given a type name and a package context, fetches the type provider for the given type.PServiceProvidergetServiceProvider(java.lang.String serviceName, java.lang.String programContext)Given a service name and program context, fetches the service provider for the given service.protected static java.lang.StringqualifiedNameFromIdAndContext(java.lang.String name, java.lang.String context)Make a qualified type name from a name identifier string and the program context.<T> voidregisterRecursively(PDeclaredDescriptor<T> declaredType)Register a declared type recursively.voidregisterRecursively(PService service)Register the service recursively.voidregisterTypedef(java.lang.String identifier, java.lang.String program, java.lang.String target)Registers a typedef definition.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.morimekta.providence.util.TypeRegistry
getConstantValue, getDeclaredType, getDeclaredType, getEnumType, getMessageType, getService, getService
-
Methods inherited from interface net.morimekta.providence.util.WritableTypeRegistry
register, register, registerConstant
-
-
-
-
Method Detail
-
registerTypedef
public void registerTypedef(@Nonnull java.lang.String identifier, @Nonnull java.lang.String program, @Nonnull java.lang.String target)Description copied from interface:WritableTypeRegistryRegisters a typedef definition.- Specified by:
registerTypedefin interfaceWritableTypeRegistry- Parameters:
identifier- The typedef name (the alias) to put.program- The program context of the typedef.target- The qualified name that the name represents.
-
getProvider
@Nonnull public PDescriptorProvider getProvider(@Nonnull java.lang.String name, @Nonnull java.lang.String context, @Nullable java.util.Map<java.lang.String,java.lang.String> annotations)
Description copied from interface:TypeRegistryGiven a type name and a package context, fetches the type provider for the given type.- Specified by:
getProviderin interfaceTypeRegistry- Parameters:
name- Name of type, without any spaces.context- The program context of the reference.annotations- Annotations affecting the type.- Returns:
- The type provider.
-
getServiceProvider
@Nonnull public PServiceProvider getServiceProvider(java.lang.String serviceName, java.lang.String programContext)
Description copied from interface:TypeRegistryGiven a service name and program context, fetches the service provider for the given service.- Specified by:
getServiceProviderin interfaceTypeRegistry- Parameters:
serviceName- Name of the service.programContext- The program context of the reference.- Returns:
- The service provider.
-
registerRecursively
public void registerRecursively(@Nonnull PService service)Description copied from interface:WritableTypeRegistryRegister the service recursively. E.g. if the service extends a different service, make sure to register that service too.- Specified by:
registerRecursivelyin interfaceWritableTypeRegistry- Parameters:
service- the service to register.
-
registerRecursively
public <T> void registerRecursively(PDeclaredDescriptor<T> declaredType)
Description copied from interface:WritableTypeRegistryRegister a declared type recursively. If the type is a message, then iterate through the fields and register those types recursively.- Specified by:
registerRecursivelyin interfaceWritableTypeRegistry- Type Parameters:
T- The declared java type.- Parameters:
declaredType- The descriptor for the type.
-
finalTypename
protected java.lang.String finalTypename(java.lang.String typeName, java.lang.String programContext)Get the final typename of the given identifier within the context.- Parameters:
typeName- The identifier name.programContext- The program context.- Returns:
- The final typename.
-
qualifiedNameFromIdAndContext
protected static java.lang.String qualifiedNameFromIdAndContext(java.lang.String name, java.lang.String context)Make a qualified type name from a name identifier string and the program context.- Parameters:
name- The type name.context- The program context.- Returns:
- The qualified name containing program name and type name.
-
-