Modifier and Type | Method and Description |
---|---|
static void |
applyBindings(Object model)
Apply bindings of a model class to overall page.
|
static void |
applyBindings(Object model,
String targetId)
Apply bindings of a model class.
|
static <T> 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,
Class<M> model,
Object jsonObject)
Converts an existing, raw, JSON object into a
model class . |
static boolean |
isModel(Class<?> clazz)
Finds out whether given class is a model class - e.g.
|
static <M> M |
parse(BrwsrCtx c,
Class<M> model,
InputStream is)
Generic method to parse content of a model class from a stream.
|
static <M> void |
parse(BrwsrCtx c,
Class<M> model,
InputStream is,
Collection<? super M> collectTo)
Generic method to parse stream, that can possibly contain array
of specified objects.
|
static Object |
toRaw(Object model)
Converts an existing
model into its associated, raw
JSON object. |
public static boolean isModel(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
IllegalArgumentException
- in case the instance is not generated by model interfacepublic static <M> M parse(BrwsrCtx c, Class<M> model, InputStream is) throws 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 dataIOException
- throw when reading from is
faces problemspublic static <M> void parse(BrwsrCtx c, Class<M> model, InputStream is, Collection<? super M> collectTo) throws 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 collectionIOException
- thrown when an I/O problem appearspublic static <M> M fromRaw(BrwsrCtx ctx, Class<M> model, 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 Object toRaw(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)IllegalArgumentException
- if the model
is
not instance of a class
generated by model annotation
processor.public static void applyBindings(Object model)
model
- instance of a class
IllegalArgumentException
- if the model
is not
instance of a class generated by model annotation
processor.public static void applyBindings(Object model, String targetId)
model
- instance of a class
targetId
- the id of the element to apply the binding toIllegalArgumentException
- if the model
is not
instance of a class generated by model annotation
processor.public static <T> 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.