@FunctionalInterface public interface TypedModelSpec<M,P1>
Abstraction that allows the construction of ModelSpecs using strongly typed parameter replacements.
For example, given a ModelSpec with a path such as "/root/registry/people/{id}" where "id" should
be PersonId
.
// Step 1. Create a typed ZPath
TypedZPath<PersonId> typedPath = TypedZPath.from("/root/registry/people/{id}");
// Step 2. Create a ModelSpec builder (do not build at this point)
ModelSpecBuilder<Person> builder = ModelSpec.builder(JacksonModelSerializer.build(Person.class))
// Step 3. Create a typed ModelSpec using the typed ZPath and ModelSpec builder
TypedModelSpec<Person, PersonId> typedModelSpec = TypedModelSpec.from(builder, path);
// later on the TypedModelSpec can be resolved into a useable ModelSpec
ModelSpec<Person> modelSpec = typedModelSpec.resolve(personId);
Modifier and Type | Method and Description |
---|---|
static <M,P1> TypedModelSpec<M,P1> |
from(ModelSpecBuilder<M> builder,
String pathWithIds)
Return a new TypedModelSpec using the given model spec builder and path.
|
static <M,P1> TypedModelSpec<M,P1> |
from(ModelSpecBuilder<M> builder,
TypedZPath<P1> path)
Return a new TypedModelSpec using the given model spec builder and typed path.
|
ModelSpec<M> |
resolved(P1 p1)
Resolve into a ZPath using the given parameter
|
ModelSpec<M> resolved(P1 p1)
p1
- the parameterstatic <M,P1> TypedModelSpec<M,P1> from(ModelSpecBuilder<M> builder, TypedZPath<P1> path)
resolved(Object)
is called the actual model spec is generated with the
resolved pathbuilder
- model spec builderpath
- typed pathstatic <M,P1> TypedModelSpec<M,P1> from(ModelSpecBuilder<M> builder, String pathWithIds)
resolved(Object)
is called the actual model spec is generated with the
resolved pathbuilder
- model spec builderpathWithIds
- typed pathCopyright © 2011–2023 The Apache Software Foundation. All rights reserved.