Package net.morimekta.providence.reflect
Class GlobalRegistry
- java.lang.Object
-
- net.morimekta.providence.types.TypeRegistry
-
- net.morimekta.providence.reflect.GlobalRegistry
-
public class GlobalRegistry extends TypeRegistry
A global type registry containing lots of individual program registries for each program. The program registry is a wrapper around a set of type registries for each of a set of different files. The individual registries are identified by thepath
to the thrift file that was parsed.
-
-
Constructor Summary
Constructors Constructor Description GlobalRegistry()
Create an empty program registry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> java.util.Optional<T>
getConstantValue(TypeReference reference)
This is to check to find a constant given the const name and program context.java.util.Optional<PDeclaredDescriptor<?>>
getDeclaredType(TypeReference reference)
Get the declared type with the given name and program context.java.util.List<PDeclaredDescriptor<?>>
getDeclaredTypes()
java.util.List<ProgramRegistry>
getRegistries()
java.util.Optional<PService>
getService(TypeReference reference)
Get a service definition from the name and program context.java.util.Optional<TypeReference>
getTypedef(TypeReference reference)
Get a type-definition for the given reference.boolean
isKnownProgram(java.lang.String program)
ProgramRegistry
registryForPath(java.lang.String filePath)
-
Methods inherited from class net.morimekta.providence.types.TypeRegistry
finalTypeReference, getServiceProvider, getTypeProvider, getTypeProvider, requireDeclaredType, requireEnumType, requireMessageType, requireService
-
-
-
-
Method Detail
-
registryForPath
@Nonnull public ProgramRegistry registryForPath(java.lang.String filePath)
-
getRegistries
public java.util.List<ProgramRegistry> getRegistries()
-
getDeclaredType
@Nonnull public java.util.Optional<PDeclaredDescriptor<?>> getDeclaredType(@Nonnull TypeReference reference)
Description copied from class:TypeRegistry
Get the declared type with the given name and program context.- Specified by:
getDeclaredType
in classTypeRegistry
- Parameters:
reference
- The reference to the type.- Returns:
- Optional type descriptor.
-
getService
@Nonnull public java.util.Optional<PService> getService(@Nonnull TypeReference reference)
Description copied from class:TypeRegistry
Get a service definition from the name and program context.- Specified by:
getService
in classTypeRegistry
- Parameters:
reference
- The service reference.- Returns:
- Optional service descriptor.
-
getConstantValue
@Nonnull public <T> java.util.Optional<T> getConstantValue(@Nonnull TypeReference reference)
Description copied from class:TypeRegistry
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.- Specified by:
getConstantValue
in classTypeRegistry
- Type Parameters:
T
- The returned value type.- Parameters:
reference
- The constant reference.- Returns:
- The optional const value.
-
getTypedef
@Nonnull public java.util.Optional<TypeReference> getTypedef(@Nonnull TypeReference reference)
Description copied from class:TypeRegistry
Get a type-definition for the given reference.- Specified by:
getTypedef
in classTypeRegistry
- Parameters:
reference
- The typedef reference.- Returns:
- Optional typedef definition.
-
getDeclaredTypes
public java.util.List<PDeclaredDescriptor<?>> getDeclaredTypes()
- Specified by:
getDeclaredTypes
in classTypeRegistry
-
isKnownProgram
public boolean isKnownProgram(@Nonnull java.lang.String program)
- Specified by:
isKnownProgram
in classTypeRegistry
- Parameters:
program
- The program name.- Returns:
- True if the program is known in this registry.
-
-