Base toolkit for serializers, parsers, and bean contexts
The {@link org.apache.juneau.BeanContext} class is the core class in the Juneau architecture. It serves multiple functions...
The {@link org.apache.juneau.BeanMap} class allows you to access the properties of a bean through the familiar {@code Map} interface. So, for example, you can use the {@code Map.get(key)} method to retrieve a property value in leu of it's getter method, and the {@code Map.put(key, value)} method to set a property value in leu of it's setter method.
The serialization and parsing of beans in Juneau is accomplished by wrapping Java beans inside instances of the class {@code BeanMap}.
Note: Instances of {@link org.apache.juneau.BeanMap} objects are always retrieved through the {@link org.apache.juneau.BeanContext} class. You cannot instantiate {@code BeanMaps} directly since the rules for defining what constitutes a bean depend on various settings in the bean context.
In general, the performance on using the {@link org.apache.juneau.BeanMap} class to access properties is equivalent to using reflection directly.
See the {@link org.apache.juneau.BeanMap} javadoc for more information.
The {@link org.apache.juneau.BeanContext} and {@link org.apache.juneau.BeanSession} classes are the workhorse class used to wrap Java beans inside {@link org.apache.juneau.BeanMap BeanMaps}. There are several options provided on the {@link org.apache.juneau.BeanContext} class to tailor the definition of a bean.
The following is a very simple example of how to wrap a bean inside a {@link org.apache.juneau.BeanMap} wrapper and use the wrapper interface to get and set property values on the bean. In this case, we're using the DEFAULT bean context.
There are 2 ways to get an instance of a {@link org.apache.juneau.BeanContext}:
The {@link org.apache.juneau.BeanContext} class is a highly-customizable class. See the {@link org.apache.juneau.BeanContext} javadoc for more information.
Juneau provides the following annotations that can be used to fine-tune what properties are associated with beans:
These annotations always override the settings defined in the {@link org.apache.juneau.BeanContext} class.
For example, the following bean class will only have one property associated with it,
When this bean is serialized using one of the {@link org.apache.juneau.serializer.Serializer Serializers}, the age property will be ignored.
Using the
It should be noted that the {@link org.apache.juneau.transform.BeanFilter} class can also be used to exclude properties from beans. However, only the annotations can be used to include non-standard properties or override property names.
See the {@link org.apache.juneau.annotation.Bean}, {@link org.apache.juneau.annotation.BeanProperty}, {@link org.apache.juneau.annotation.BeanConstructor}, and {@link org.apache.juneau.annotation.BeanIgnore} javadocs for more information.