Interface ModelSpec<T>

All Superinterfaces:
Resolvable
All Known Implementing Classes:
ModelSpecImpl

public interface ModelSpec<T> extends Resolvable
A full specification for dealing with a portion of the ZooKeeper tree. ModelSpec's contain:
  • A node path
  • Serializer for the data stored
  • Options for how to create the node (mode, compression, etc.)
  • Options for how to deleting the node (quietly, guaranteed, etc.)
  • ACLs
  • Optional schema generation
  • Field Details

    • defaultCreateOptions

      static final Set<CreateOption> defaultCreateOptions
    • defaultDeleteOptions

      static final Set<DeleteOption> defaultDeleteOptions
  • Method Details

    • builder

      static <T> ModelSpecBuilder<T> builder(ZPath path, ModelSerializer<T> serializer)
      Start a new ModelSpecBuilder for the given path and serializer. The returned ModelSpecBuilder uses defaultCreateOptions and defaultDeleteOptions, but you can change these with builder methods.
      Parameters:
      path - path to model
      serializer - the model's serializer
      Returns:
      builder
    • builder

      static <T> ModelSpecBuilder<T> builder(ModelSerializer<T> serializer)
      Start a new ModelSpecBuilder for the given serializer. The returned ModelSpecBuilder uses defaultCreateOptions and defaultDeleteOptions, but you can change these with builder methods. You must set a path before calling ModelSpecBuilder.build()
      Parameters:
      serializer - the model's serializer
      Returns:
      builder
    • child

      ModelSpec<T> child(Object child)

      Return a new CuratorModel instance with all the same options but applying to the given child node of this CuratorModel's path. E.g. if this CuratorModel instance applies to "/a/b", calling modeled.at("c") returns an instance that applies to "/a/b/c".

      The replacement is the toString() value of child or, if it implements NodeName, the value of nodeName().

      Parameters:
      child - child node.
      Returns:
      new Modeled Spec instance
    • parent

      ModelSpec<T> parent()

      Return a new CuratorModel instance with all the same options but applying to the parent node of this CuratorModel's path. E.g. if this CuratorModel instance applies to "/a/b/c", calling modeled.parent() returns an instance that applies to "/a/b".

      The replacement is the toString() value of child or, if it implements NodeName, the value of nodeName().

      Returns:
      new Modeled Spec instance
    • withPath

      ModelSpec<T> withPath(ZPath path)
      Return a new CuratorModel instance with all the same options but using the given path.
      Parameters:
      path - new path
      Returns:
      new Modeled Spec instance
    • resolved

      ModelSpec<T> resolved(Object... parameters)

      Return a new CuratorModel instance with all the same options but using a resolved path by calling ZPath.resolved(Object...) using the given parameters

      The replacement is the toString() value of the parameter object or, if the object implements NodeName, the value of nodeName().

      Specified by:
      resolved in interface Resolvable
      Parameters:
      parameters - list of replacements. Must have be the same length as the number of parameter nodes in the path
      Returns:
      new resolved ModelSpec
    • resolved

      ModelSpec<T> resolved(List<Object> parameters)

      Return a new CuratorModel instance with all the same options but using a resolved path by calling ZPath.resolved(java.util.List) using the given parameters

      The replacement is the toString() value of the parameter object or, if the object implements NodeName, the value of nodeName().

      Specified by:
      resolved in interface Resolvable
      Parameters:
      parameters - list of replacements. Must have be the same length as the number of parameter nodes in the path
      Returns:
      new resolved ModelSpec
    • path

      ZPath path()
      Return the model's path
      Returns:
      path
    • serializer

      ModelSerializer<T> serializer()
      Return the model's serializer
      Returns:
      serializer
    • createMode

      org.apache.zookeeper.CreateMode createMode()
      Return the model's create mode
      Returns:
      create mode
    • aclList

      List<org.apache.zookeeper.data.ACL> aclList()
      Return the model's ACL list
      Returns:
      ACL list
    • createOptions

      Set<CreateOption> createOptions()
      Return the model's create options
      Returns:
      create options
    • deleteOptions

      Set<DeleteOption> deleteOptions()
      Return the model's delete options
      Returns:
      delete options
    • ttl

      long ttl()
      Return the TTL to use or -1
      Returns:
      ttl
    • schema

      Schema schema()
      Return a Curator schema that validates ZNodes at this model's path using this model's values
      Returns:
      schema