Package net.morimekta.providence.util
Class SimpleTypeRegistry
- java.lang.Object
-
- net.morimekta.providence.util.BaseTypeRegistry
-
- net.morimekta.providence.util.SimpleTypeRegistry
-
- All Implemented Interfaces:
TypeRegistry
,WritableTypeRegistry
public class SimpleTypeRegistry extends BaseTypeRegistry
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. Note that this registry does not handle situations where two programs with the same name exist with a type each with the same name.
-
-
Constructor Summary
Constructors Constructor Description SimpleTypeRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
getConstantValue(java.lang.String constReference, java.lang.String programContext)
This is to check to find a constant given the const name and program context.<T extends PDeclaredDescriptor<T>>
TgetDeclaredType(java.lang.String typeName, java.lang.String programContext)
Get the declared type with the given name and program context.PService
getService(java.lang.String serviceName, java.lang.String programContext)
Get a service definition from the name and program context.<T> boolean
register(PDeclaredDescriptor<T> declaredType)
Register a declared type.boolean
register(PService service)
Services are not handled as "declared types", so they need to be registered separately.void
registerConstant(java.lang.String identifier, java.lang.String program, java.lang.Object value)
Register a constant value.-
Methods inherited from class net.morimekta.providence.util.BaseTypeRegistry
finalTypename, getProvider, getServiceProvider, qualifiedNameFromIdAndContext, registerRecursively, registerRecursively, registerTypedef
-
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
getDeclaredType, getEnumType, getMessageType, getService
-
-
-
-
Method Detail
-
getDeclaredType
@Nonnull public <T extends PDeclaredDescriptor<T>> T getDeclaredType(@Nonnull java.lang.String typeName, @Nonnull java.lang.String programContext)
Description copied from interface:TypeRegistry
Get the declared type with the given name and program context.- Type Parameters:
T
- The described type.- Parameters:
typeName
- The type name.programContext
- The program context of the type.- Returns:
- The declared type descriptor.
-
getConstantValue
@Nullable public <T> T getConstantValue(@Nonnull java.lang.String constReference, @Nonnull java.lang.String programContext)
Description copied from interface:TypeRegistry
This is to check to find a constant given the const name and program context. This will return null if the constant does not exist.- Type Parameters:
T
- The returned value type.- Parameters:
constReference
- The reference to the constant.programContext
- The current program context.- Returns:
- The const value or null.
-
getService
@Nonnull public PService getService(java.lang.String serviceName, java.lang.String programContext)
Description copied from interface:TypeRegistry
Get a service definition from the name and program context.- Parameters:
serviceName
- The service name.programContext
- The program context name to get the service in.- Returns:
- The service or null if not found.
-
registerConstant
public void registerConstant(@Nonnull java.lang.String identifier, @Nonnull java.lang.String program, @Nonnull java.lang.Object value)
Description copied from interface:WritableTypeRegistry
Register a constant value.- Parameters:
identifier
- The constant identifier name.program
- The program context for the constant.value
- The parsed value.
-
register
public boolean register(@Nonnull PService service)
Description copied from interface:WritableTypeRegistry
Services are not handled as "declared types", so they need to be registered separately.- Parameters:
service
- the service to register.- Returns:
- True if the service was registered and not already known.
-
register
public <T> boolean register(PDeclaredDescriptor<T> declaredType)
Description copied from interface:WritableTypeRegistry
Register a declared type.- Type Parameters:
T
- The declared java type.- Parameters:
declaredType
- The descriptor for the type.- Returns:
- True if the type was registered
-
-