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 protected
BaseTypeRegistry()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
finalTypename(java.lang.String typeName, java.lang.String programContext)
Get the final typename of the given identifier within the context.PDescriptorProvider
getProvider(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.PServiceProvider
getServiceProvider(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.String
qualifiedNameFromIdAndContext(java.lang.String name, java.lang.String context)
Make a qualified type name from a name identifier string and the program context.<T> void
registerRecursively(PDeclaredDescriptor<T> declaredType)
Register a declared type recursively.void
registerRecursively(PService service)
Register the service recursively.void
registerTypedef(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:WritableTypeRegistry
Registers a typedef definition.- Specified by:
registerTypedef
in 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:TypeRegistry
Given a type name and a package context, fetches the type provider for the given type.- Specified by:
getProvider
in 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:TypeRegistry
Given a service name and program context, fetches the service provider for the given service.- Specified by:
getServiceProvider
in 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:WritableTypeRegistry
Register the service recursively. E.g. if the service extends a different service, make sure to register that service too.- Specified by:
registerRecursively
in interfaceWritableTypeRegistry
- Parameters:
service
- the service to register.
-
registerRecursively
public <T> void registerRecursively(PDeclaredDescriptor<T> declaredType)
Description copied from interface:WritableTypeRegistry
Register a declared type recursively. If the type is a message, then iterate through the fields and register those types recursively.- Specified by:
registerRecursively
in 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.
-
-