Class ProgramRegistry


  • public class ProgramRegistry
    extends net.morimekta.providence.types.WritableTypeRegistry
    This is a registry for a single program. Meaning it also handles how includes work and contains meta info about the program it is representing. The registry can reference each other recursively. Each registry will have a specific package context, and needs to be built up in a recursive manner. This way each type registry will only have access to the described types actually referenced and included in the given thrift program file.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> java.util.Optional<T> getConstantValue​(net.morimekta.providence.types.TypeReference reference)  
      java.util.Optional<net.morimekta.providence.descriptor.PDeclaredDescriptor<?>> getDeclaredType​(net.morimekta.providence.types.TypeReference reference)  
      java.util.List<net.morimekta.providence.descriptor.PDeclaredDescriptor<?>> getDeclaredTypes()  
      CProgram getProgram()  
      java.lang.String getProgramContext()  
      ProgramDeclaration getProgramType()  
      java.util.Optional<ProgramRegistry> getRegistry​(java.lang.String program)  
      java.util.Optional<net.morimekta.providence.descriptor.PService> getService​(net.morimekta.providence.types.TypeReference reference)  
      java.util.Optional<net.morimekta.providence.types.TypeReference> getTypedef​(net.morimekta.providence.types.TypeReference reference)  
      boolean isKnownProgram​(java.lang.String program)  
      void registerConstant​(net.morimekta.providence.types.TypeReference reference, net.morimekta.providence.descriptor.PValueProvider value)  
      void registerService​(net.morimekta.providence.descriptor.PService service)  
      <T> void registerType​(net.morimekta.providence.descriptor.PDeclaredDescriptor<T> declaredType)  
      void registerTypedef​(net.morimekta.providence.types.TypeReference reference, net.morimekta.providence.types.TypeReference target)  
      • Methods inherited from class net.morimekta.providence.types.TypeRegistry

        finalTypeReference, getServiceProvider, getTypeProvider, getTypeProvider, requireDeclaredType, requireEnumType, requireMessageType, requireService
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getProgramContext

        public java.lang.String getProgramContext()
      • getProgram

        public CProgram getProgram()
      • getRegistry

        @Nonnull
        public java.util.Optional<ProgramRegistry> getRegistry​(@Nonnull
                                                               java.lang.String program)
      • getDeclaredType

        @Nonnull
        public java.util.Optional<net.morimekta.providence.descriptor.PDeclaredDescriptor<?>> getDeclaredType​(@Nonnull
                                                                                                              net.morimekta.providence.types.TypeReference reference)
        Specified by:
        getDeclaredType in class net.morimekta.providence.types.TypeRegistry
      • getService

        @Nonnull
        public java.util.Optional<net.morimekta.providence.descriptor.PService> getService​(@Nonnull
                                                                                           net.morimekta.providence.types.TypeReference reference)
        Specified by:
        getService in class net.morimekta.providence.types.TypeRegistry
      • getConstantValue

        @Nonnull
        public <T> java.util.Optional<T> getConstantValue​(@Nonnull
                                                          net.morimekta.providence.types.TypeReference reference)
        Specified by:
        getConstantValue in class net.morimekta.providence.types.TypeRegistry
      • getTypedef

        @Nonnull
        public java.util.Optional<net.morimekta.providence.types.TypeReference> getTypedef​(@Nonnull
                                                                                           net.morimekta.providence.types.TypeReference reference)
        Specified by:
        getTypedef in class net.morimekta.providence.types.TypeRegistry
      • getDeclaredTypes

        public java.util.List<net.morimekta.providence.descriptor.PDeclaredDescriptor<?>> getDeclaredTypes()
        Specified by:
        getDeclaredTypes in class net.morimekta.providence.types.TypeRegistry
      • isKnownProgram

        public boolean isKnownProgram​(@Nonnull
                                      java.lang.String program)
        Specified by:
        isKnownProgram in class net.morimekta.providence.types.TypeRegistry
      • registerTypedef

        public void registerTypedef​(@Nonnull
                                    net.morimekta.providence.types.TypeReference reference,
                                    @Nonnull
                                    net.morimekta.providence.types.TypeReference target)
        Specified by:
        registerTypedef in class net.morimekta.providence.types.WritableTypeRegistry
      • registerType

        public <T> void registerType​(net.morimekta.providence.descriptor.PDeclaredDescriptor<T> declaredType)
        Specified by:
        registerType in class net.morimekta.providence.types.WritableTypeRegistry
      • registerService

        public void registerService​(@Nonnull
                                    net.morimekta.providence.descriptor.PService service)
        Specified by:
        registerService in class net.morimekta.providence.types.WritableTypeRegistry
      • registerConstant

        public void registerConstant​(@Nonnull
                                     net.morimekta.providence.types.TypeReference reference,
                                     @Nonnull
                                     net.morimekta.providence.descriptor.PValueProvider value)
        Specified by:
        registerConstant in class net.morimekta.providence.types.WritableTypeRegistry