Package net.morimekta.providence.types
Class TypeRegistry
- java.lang.Object
-
- net.morimekta.providence.types.TypeRegistry
-
- Direct Known Subclasses:
WritableTypeRegistry
public abstract class TypeRegistry extends java.lang.Object
Base class for type registry. The type registry holds type information, possibly with some context, and has methods to get type information out from the registry.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TypeRegistry()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected TypeReference
finalTypeReference(TypeReference reference)
Get the final typename of the given identifier within the context.abstract <T> java.util.Optional<T>
getConstantValue(TypeReference reference)
This is to check to find a constant given the const name and program context.abstract java.util.Optional<PDeclaredDescriptor<?>>
getDeclaredType(TypeReference reference)
Get the declared type with the given name and program context.abstract java.util.List<PDeclaredDescriptor<?>>
getDeclaredTypes()
abstract java.util.Optional<PService>
getService(TypeReference reference)
Get a service definition from the name and program context.PServiceProvider
getServiceProvider(TypeReference reference)
abstract java.util.Optional<TypeReference>
getTypedef(TypeReference reference)
Get a type-definition for the given reference.PDescriptorProvider
getTypeProvider(TypeReference reference)
Get a type provider for reference.PDescriptorProvider
getTypeProvider(TypeReference reference, java.util.Map<java.lang.String,java.lang.String> annotations)
abstract boolean
isKnownProgram(java.lang.String program)
PDeclaredDescriptor
requireDeclaredType(TypeReference reference)
Get the declared type with the given name and program context.<E extends PEnumValue<E>>
PEnumDescriptor<E>requireEnumType(TypeReference reference)
Get the declared enum type.<M extends PMessage<M>>
PMessageDescriptor<M>requireMessageType(TypeReference reference)
Get the declared message type.PService
requireService(TypeReference reference)
Get the declared type with the given name and program context.
-
-
-
Method Detail
-
getDeclaredType
@Nonnull public abstract java.util.Optional<PDeclaredDescriptor<?>> getDeclaredType(@Nonnull TypeReference reference)
Get the declared type with the given name and program context.- Parameters:
reference
- The reference to the type.- Returns:
- Optional type descriptor.
-
getService
@Nonnull public abstract java.util.Optional<PService> getService(@Nonnull TypeReference reference)
Get a service definition from the name and program context.- Parameters:
reference
- The service reference.- Returns:
- Optional service descriptor.
-
getConstantValue
@Nonnull public abstract <T> java.util.Optional<T> getConstantValue(@Nonnull TypeReference reference)
This is to check to find a constant given the const name and program context. This will return empty if the constant does not exist.- Type Parameters:
T
- The returned value type.- Parameters:
reference
- The constant reference.- Returns:
- The optional const value.
-
getTypedef
@Nonnull public abstract java.util.Optional<TypeReference> getTypedef(@Nonnull TypeReference reference)
Get a type-definition for the given reference.- Parameters:
reference
- The typedef reference.- Returns:
- Optional typedef definition.
-
getDeclaredTypes
public abstract java.util.List<PDeclaredDescriptor<?>> getDeclaredTypes()
-
isKnownProgram
public abstract boolean isKnownProgram(@Nonnull java.lang.String program)
- Parameters:
program
- The program name.- Returns:
- True if the program is known in this registry.
-
requireDeclaredType
@Nonnull public PDeclaredDescriptor requireDeclaredType(@Nonnull TypeReference reference)
Get the declared type with the given name and program context.- Parameters:
reference
- The reference to the type.- Returns:
- The declared type descriptor.
-
requireMessageType
@Nonnull public <M extends PMessage<M>> PMessageDescriptor<M> requireMessageType(@Nonnull TypeReference reference)
Get the declared message type.- Type Parameters:
M
- The message type.- Parameters:
reference
- The type reference.- Returns:
- The message type descriptor.
-
requireEnumType
@Nonnull public <E extends PEnumValue<E>> PEnumDescriptor<E> requireEnumType(@Nonnull TypeReference reference)
Get the declared enum type.- Type Parameters:
E
- The enum value type.- Parameters:
reference
- The type reference.- Returns:
- The enum type descriptor.
-
requireService
@Nonnull public PService requireService(@Nonnull TypeReference reference)
Get the declared type with the given name and program context.- Parameters:
reference
- The reference to the type.- Returns:
- The service descriptor.
-
getTypeProvider
@Nonnull public PDescriptorProvider getTypeProvider(@Nonnull TypeReference reference)
Get a type provider for reference.- Parameters:
reference
- Type reference to get provider for.- Returns:
- The type provider.
-
getTypeProvider
@Nonnull public PDescriptorProvider getTypeProvider(@Nonnull TypeReference reference, @Nonnull java.util.Map<java.lang.String,java.lang.String> annotations)
-
getServiceProvider
@Nonnull public PServiceProvider getServiceProvider(@Nonnull TypeReference reference)
-
finalTypeReference
@Nonnull protected TypeReference finalTypeReference(@Nonnull TypeReference reference)
Get the final typename of the given identifier within the context.- Parameters:
reference
- The type name.- Returns:
- The final type reference.
-
-