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

public interface BeanSession
Minimum runtime surface that the bean-modeling layer needs from a marshalling session.

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 null and these operations are skipped; the bean-modeling code runs in raw-reflection mode.

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:
  • Method Details

    • convertToType

      Object convertToType(Object value, Object targetType)
      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 through MarshallingSession.convertToType(Object, ClassMeta).

      Parameters:
      value - The value to convert. May be null.
      targetType - The target type — typically a marshalling-side ClassMeta<?> handle passed through from a BeanPropertyMeta or BeanMap. Must not be null.
      Returns:
      The converted value.
    • convertToMemberType

      Object convertToMemberType(Object outer, Object value, Object targetType)
      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 be null.
      value - The value to convert. May be null.
      targetType - The target type — typically a marshalling-side ClassMeta<?>. Must not be null.
      Returns:
      The converted value.
    • parseToMap

      Parses the specified JSON-formatted character sequence into a Map.

      Used by BeanPropertyMeta.setPropertyValue when a CharSequence value is supplied for a Map-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 be null.
      Returns:
      The parsed map.
    • parseToList

      Parses the specified JSON-formatted character sequence into a Collection.

      Used by BeanPropertyMeta.setPropertyValue when a CharSequence value is supplied for a Collection-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 be null.
      Returns:
      The parsed collection.
    • toBeanMap

      <T> Object toBeanMap(T bean)
      Wraps the specified bean in a BeanMap.

      Equivalent to MarshallingSession.toBeanMap(Object) on the marshalling-side. The return type is typed as Object (rather than BeanMap) because the bean-modeling BeanMap runtime type currently lives in juneau-marshall; callers in commons.bean treat the returned value opaquely and pass it through to other BeanSession / 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 be null.
      Returns:
      A new bean map (typically a BeanMap) wrapping the supplied bean.
    • isPropertyInActiveView

      default boolean isPropertyInActiveView(BeanPropertyMeta pMeta)
      Returns true 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-side MarshallingSession overrides 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 be null.
      Returns:
      true if the property should be included under the current active view.