Class TypeRegistry

java.lang.Object
net.tangly.core.TypeRegistry

public class TypeRegistry extends Object
Registry of tag types defined for a domain model.
  • Constructor Details

    • TypeRegistry

      public TypeRegistry()
  • Method Details

    • register

      public void register(@NotNull @NotNull TagType<?> type)
      Registers a tag type.
      Parameters:
      type - tag type to bind
    • tagTypes

      public Collection<TagType<?>> tagTypes()
    • namespaces

      public List<String> namespaces()
      Returns all the namespaces registered.
      Returns:
      List of namespaces
    • tagNamesForNamespace

      public List<String> tagNamesForNamespace(@NotNull @NotNull String namespace)
    • find

      public <T> Optional<TagType<T>> find(String namespace, @NotNull @NotNull String name)
      Returns the tag type describing the requested namespace and name.
      Type Parameters:
      T - type of the code
      Parameters:
      namespace - optional namespace of the tag type
      name - mandatory name of the tag type
      Returns:
      requested tag type as optional
    • find

      public <T> Optional<TagType<T>> find(@NotNull @NotNull Tag tag)
      Returns the tag type describing the tag.
      Type Parameters:
      T - type of the code
      Parameters:
      tag - tag which type is requested
      Returns:
      requested tag type
      See Also:
    • register

      public <T extends Code> void register(@NotNull @NotNull CodeType<T> type)
      Registers a code type to the registry.
      Type Parameters:
      T - type of the code
      Parameters:
      type - code type to register
    • find

      public <T extends Code> Optional<CodeType<T>> find(@NotNull @NotNull Class<T> clazz)
      Returns the code type for the provided code class. The implementation takes care to return the expected generic type.
      Type Parameters:
      T - type of code to look for
      Parameters:
      clazz - class of the code which code type we are looking for
      Returns:
      code type as optional