Interface BeanSession
- All Known Implementing Classes:
BsonParserSession,BsonSerializerSession,CborParserSession,CborSerializerSession,CsvParserSession,CsvSerializerSession,HjsonParserSession,HjsonSerializerSession,HoconParserSession,HoconSerializerSession,HtmlDocSerializerSession,HtmlParserSession,HtmlSchemaDocSerializerSession,HtmlSchemaSerializerSession,HtmlSerializerSession,HtmlStrippedDocSerializerSession,IniParserSession,IniSerializerSession,InputStreamParserSession,JcsSerializerSession,Json5lParserSession,Json5lSerializerSession,Json5ParserSession,Json5SerializerSession,JsonlParserSession,JsonlSerializerSession,JsonParserSession,JsonSchemaGeneratorSession,JsonSchemaSerializerSession,JsonSerializerSession,MarkdownDocParserSession,MarkdownDocSerializerSession,MarkdownParserSession,MarkdownSerializerSession,MarshallingSession,MarshallingTraverseSession,MockRestRequest,MsgPackParserSession,MsgPackSerializerSession,OpenApiParserSession,OpenApiSerializerSession,OutputStreamSerializerSession,ParquetParserSession,ParquetSerializerSession,ParserSession,PlainTextParserSession,PlainTextSerializerSession,RdfParserSession,RdfSerializerSession,RdfStreamParserSession,RdfStreamSerializerSession,ReaderParserSession,RestRequest,SerializerSession,SoapXmlSerializerSession,SseParserSession,SseSerializerSession,TomlParserSession,TomlSerializerSession,UonParserSession,UonSerializerSession,UrlEncodingParserSession,UrlEncodingSerializerSession,WriterSerializerSession,XmlDocSerializerSession,XmlParserSession,XmlSerializerSession,YamlParserSession,YamlSerializerSession
BeanSession is an SPI seam between the bean-modeling runtime (in commons.bean) and the
marshalling stack (in juneau-marshall). The marshalling layer's MarshallingSession
implements this interface so the bean-modeling types (notably BeanMap and BeanPropertyMeta)
can request session-aware operations — type conversion, bean-map wrapping — without referencing any
marshalling-aware concrete types.
On the commons-side construction path (BeanMeta.of(Class, BeanConfigContext)) the session is
Method parameter typing:
The targetType parameters are typed as Object because the marshalling layer expresses them
as ClassMeta<?> — a marshalling-side type that commons.bean cannot reference. Callers in
the bean-modeling layer pass through whatever opaque type-metadata handle they received; the
MarshallingSession implementation interprets it as a ClassMeta.
Thread safety
Thread safety depends on implementation.See Also:
BeanConfigContext— bean-modeling configuration counterpart.
-
Method Summary
Modifier and TypeMethodDescriptionconvertToMemberType(Object outer, Object value, Object targetType) Converts the specified value to the specified target type, instantiating non-static inner classes against an outer instance.convertToType(Object value, Object targetType) Converts the specified value to the specified target type.default booleanReturnstrue if the specified bean property is visible under the current active view.Collection<?>parseToList(CharSequence value) Parses the specified JSON-formatted character sequence into aCollection.Map<?,?> parseToMap(CharSequence value) Parses the specified JSON-formatted character sequence into aMap.<T> ObjecttoBeanMap(T bean) Wraps the specified bean in aBeanMap.
-
Method Details
-
convertToType
Converts the specified value to the specified target type.Implementations apply any registered conversions, swaps, or coercions necessary to produce a value compatible with
targetType. On the marshalling-side, this routes throughMarshallingSession.convertToType(Object, ClassMeta).- Parameters:
value- The value to convert. May benull .targetType- The target type — typically a marshalling-sideClassMeta<?>handle passed through from aBeanPropertyMetaorBeanMap. Must not benull .- Returns:
- The converted value.
-
convertToMemberType
Converts the specified value to the specified target type, instantiating non-static inner classes against an outer instance.- Parameters:
outer- The outer-class instance for non-static inner classes. May benull .value- The value to convert. May benull .targetType- The target type — typically a marshalling-sideClassMeta<?>. Must not benull .- Returns:
- The converted value.
-
parseToMap
Parses the specified JSON-formatted character sequence into aMap.Used by
BeanPropertyMeta.setPropertyValuewhen aCharSequencevalue is supplied for aMap-typed property — the bean-modeling layer cannot reference the marshalling-side JSON parser directly, so the parse is delegated to the session via this SPI.Implementations typically route through
JsonMap.ofString(value).session(this).- Parameters:
value- The JSON-formatted character sequence to parse. Must not benull .- Returns:
- The parsed map.
-
parseToList
Parses the specified JSON-formatted character sequence into aCollection.Used by
BeanPropertyMeta.setPropertyValuewhen aCharSequencevalue is supplied for aCollection-typed property — the bean-modeling layer cannot reference the marshalling-side JSON parser directly, so the parse is delegated to the session via this SPI.Implementations typically route through
new JsonList(value).setBeanSession(this).- Parameters:
value- The JSON-formatted character sequence to parse. Must not benull .- Returns:
- The parsed collection.
-
toBeanMap
Wraps the specified bean in aBeanMap.Equivalent to
MarshallingSession.toBeanMap(Object)on the marshalling-side. The return type is typed asObject(rather thanBeanMap) because the bean-modelingBeanMapruntime type currently lives injuneau-marshall; callers incommons.beantreat the returned value opaquely and pass it through to otherBeanSession/ bean-modeling APIs that re-narrow it.The signature is generic to allow implementations (notably
MarshallingSession) to satisfy this method with their existing covariant<T> BeanMap<T> toBeanMap(T)declaration without an additional bridge method.- Type Parameters:
T- The bean type.- Parameters:
bean- The bean to wrap. Must not benull .- Returns:
- A new bean map (typically a
BeanMap) wrapping the supplied bean.
-
isPropertyInActiveView
Returnstrue if the specified bean property is visible under the current active view.When no active view is set on the session, this method always returns
true (all properties visible). The marshalling-sideMarshallingSessionoverrides this to implement the actual view-membership check using the property's declared view set and the active view name.Default-view-inclusion policy (configurable): an untagged property — one whose view set is empty — is considered in-view under every active view unless the
MarshallingContext.Builder.disableDefaultViewInclusion()flag is set.- Parameters:
pMeta- The property metadata. Must not benull .- Returns:
true if the property should be included under the current active view.
-