Class AbstractModelResource

All Implemented Interfaces:
Cloneable, Resource

public abstract class AbstractModelResource extends ResourceProvider.ResourceProviderRegistry implements Resource
Abstract Resource implementation.

Concurrency note: this class is *not* thread safe

Author:
Emanuel Muckenhuber
  • Constructor Details

    • AbstractModelResource

      protected AbstractModelResource()
    • AbstractModelResource

      protected AbstractModelResource(boolean runtimeOnly)
    • AbstractModelResource

      protected AbstractModelResource(boolean runtimeOnly, String... orderedChildTypes)
    • AbstractModelResource

      protected AbstractModelResource(boolean runtimeOnly, Set<String> orderedChildTypes)
  • Method Details

    • getChild

      public Resource getChild(PathElement address)
      Description copied from interface: Resource
      Get a single child of this resource with the given address. If no such child exists this will return null.
      Specified by:
      getChild in interface Resource
      Parameters:
      address - the path element
      Returns:
      the resource, null if there is no such child resource
    • hasChild

      public boolean hasChild(PathElement address)
      Description copied from interface: Resource
      Determine whether this resource has a child with the given address. In case the PathElement has a wildcard as value, it will determine whether this resource has any resources of a given type.
      Specified by:
      hasChild in interface Resource
      Parameters:
      address - the path element
      Returns:
      true if there is child with the given address
    • requireChild

      public Resource requireChild(PathElement address)
      Description copied from interface: Resource
      Get a single child of this resource with the given address. If no such child exists a, an exception is thrown.
      Specified by:
      requireChild in interface Resource
      Parameters:
      address - the path element
      Returns:
      the resource
    • hasChildren

      public boolean hasChildren(String childType)
      Description copied from interface: Resource
      Determine whether this resource has any child of a given type.
      Specified by:
      hasChildren in interface Resource
      Parameters:
      childType - the child type
      Returns:
      true if there is any child of the given type
    • getChildrenNames

      public Set<String> getChildrenNames(String childType)
      Description copied from interface: Resource
      Get the children names for a given type.
      Specified by:
      getChildrenNames in interface Resource
      Parameters:
      childType - the child type
      Returns:
      the names of registered child resources
    • getChildTypes

      public Set<String> getChildTypes()
      Description copied from interface: Resource
      Get a list of registered child types for this resource.
      Specified by:
      getChildTypes in interface Resource
      Returns:
      the registered child types
    • getChildren

      public Set<Resource.ResourceEntry> getChildren(String childType)
      Description copied from interface: Resource
      Get the children for a given type.
      Specified by:
      getChildren in interface Resource
      Parameters:
      childType - the child type
      Returns:
      the registered children
    • registerChild

      public void registerChild(PathElement address, Resource resource)
      Description copied from interface: Resource
      Register a child resource.
      Specified by:
      registerChild in interface Resource
      Parameters:
      address - the address
      resource - the resource
    • registerChild

      public void registerChild(PathElement address, int index, Resource resource)
      Description copied from interface: Resource
      Register a child resource
      Specified by:
      registerChild in interface Resource
      Parameters:
      address - the address
      index - the index at which to add the resource. Existing children with this index and higher will be shifted one uo
      resource - the resource
    • removeChild

      public Resource removeChild(PathElement address)
      Description copied from interface: Resource
      Remove a child resource.
      Specified by:
      removeChild in interface Resource
      Parameters:
      address - the address
      Returns:
      the resource
    • isProxy

      public boolean isProxy()
      Description copied from interface: Resource
      Gets whether operations against this resource will be proxied to a remote process.
      Specified by:
      isProxy in interface Resource
      Returns:
      true if this resource represents a remote resource; false otherwise
    • isRuntime

      public boolean isRuntime()
      Description copied from interface: Resource
      Gets whether this resource only exists in the runtime and has no representation in the persistent configuration model.
      Specified by:
      isRuntime in interface Resource
      Returns:
      true if the resource has no representation in the persistent configuration model; false otherwise
    • getOrderedChildTypes

      public Set<String> getOrderedChildTypes()
      Description copied from interface: Resource
      Return the child types for which the order matters.
      Specified by:
      getOrderedChildTypes in interface Resource
      Returns:
      true if the order of the children matters. If there are no ordered children and empty set is returned. This method should never return null
    • registerResourceProvider

      protected void registerResourceProvider(String type, ResourceProvider provider)
      Specified by:
      registerResourceProvider in class ResourceProvider.ResourceProviderRegistry
    • getProvider

      protected final ResourceProvider getProvider(String type)
    • getOrCreateProvider

      protected ResourceProvider getOrCreateProvider(String type)
    • clone

      public abstract Resource clone()
      Description copied from interface: Resource
      Creates and returns a copy of this resource.
      Specified by:
      clone in interface Resource
      Overrides:
      clone in class Object
      Returns:
      the clone. Will not return null
    • cloneProviders

      protected void cloneProviders(AbstractModelResource clone)