public final class Models
extends java.lang.Object
@Model
annotation.Modifier and Type | Method and Description |
---|---|
static void |
applyBindings(java.lang.Object model)
Apply bindings of a model class to overall page.
|
static void |
applyBindings(java.lang.Object model,
java.lang.String targetId)
Apply bindings of a model class.
|
static <T> java.util.List<T> |
asList(T... values)
Wrap provided values into mutable list.
|
static <Model> Model |
bind(Model model,
BrwsrCtx context)
Binds given model to another context.
|
static <M> M |
fromRaw(BrwsrCtx ctx,
java.lang.Class<M> model,
java.lang.Object jsonObject)
Converts an existing, raw, JSON object into a
model class . |
static boolean |
isModel(java.lang.Class<?> clazz)
Finds out whether given class is a model class - e.g.
|
static <M> M |
parse(BrwsrCtx c,
java.lang.Class<M> model,
java.io.InputStream is)
Generic method to parse content of a model class from a stream.
|
static <M> void |
parse(BrwsrCtx c,
java.lang.Class<M> model,
java.io.InputStream is,
java.util.Collection<? super M> collectTo)
Generic method to parse stream, that can possibly contain array
of specified objects.
|
static java.lang.Object |
toRaw(java.lang.Object model)
Converts an existing
model into its associated, raw
JSON object. |
public static boolean isModel(java.lang.Class<?> clazz)
@Model
annotation.clazz
- the class to testclazz
was generated by Model
annotationpublic static <Model> Model bind(Model model, BrwsrCtx context)
Model
- class defined by Model
annotationmodel
- instance of a model defined by Model
annotationcontext
- context to which the model should be boundcontext
java.lang.IllegalArgumentException
- in case the instance is not generated by model interfacepublic static <M> M parse(BrwsrCtx c, java.lang.Class<M> model, java.io.InputStream is) throws java.io.IOException
M
- type of the model
classc
- context of the technology to use for readingmodel
- the model class generated by Model
annotationis
- input stream with datajava.io.IOException
- throw when reading from is
faces problemspublic static <M> void parse(BrwsrCtx c, java.lang.Class<M> model, java.io.InputStream is, java.util.Collection<? super M> collectTo) throws java.io.IOException
M
- the type of the individal JSON objectc
- context of the technology to use for readingmodel
- the model class generated by Model
annotationis
- input stream with datacollectTo
- collection to add the individual model instances to.
If the stream contains an object, one instance will be added, if
it contains an array, the number of array items will be added to
the collectionjava.io.IOException
- thrown when an I/O problem appearspublic static <M> M fromRaw(BrwsrCtx ctx, java.lang.Class<M> model, java.lang.Object jsonObject)
model class
.M
- the type of the model classctx
- context of the technology to use for convertingmodel
- the model classjsonObject
- original instance of the JSON objectpublic static java.lang.Object toRaw(java.lang.Object model)
model
into its associated, raw
JSON object. The object may, but does not have to, be the same instance
as the model object.model
- the model object
(can be null
to initialize the associated Technology
)null
if the model
parameter was null)java.lang.IllegalArgumentException
- if the model
is
not instance of a class
generated by model annotation
processor.public static void applyBindings(java.lang.Object model)
model
- instance of a class
java.lang.IllegalArgumentException
- if the model
is not
instance of a class generated by model annotation
processor.public static void applyBindings(java.lang.Object model, java.lang.String targetId)
model
- instance of a class
targetId
- the id of the element to apply the binding tojava.lang.IllegalArgumentException
- if the model
is not
instance of a class generated by model annotation
processor.public static <T> java.util.List<T> asList(T... values)
T
- type of the values and resulting listvalues
- the values, if anyCopyright © 2021 The Apache Software Foundation. All rights reserved.