Class ContextSession.Builder<SELF extends ContextSession.Builder<SELF>>

java.lang.Object
org.apache.juneau.marshall.ContextSession.Builder<SELF>
Direct Known Subclasses:
MarshallingSession.Builder, RestOpSession.Builder, RestSession.Builder
Enclosing class:
ContextSession

public abstract static class ContextSession.Builder<SELF extends ContextSession.Builder<SELF>> extends Object
Builder class.
  • Constructor Details

    • Builder

      protected Builder(Context ctx)
      Constructor.
      Parameters:
      ctx - The context creating this session.
      Cannot be null.
  • Method Details

    • self

      protected final SELF self()
      Returns this object cast to the self (CRTP) type.
      Returns:
      This object.
    • cvt

      protected static <T> T cvt(Object value, Class<T> type)
      Convenience method for converting values using BasicConverter.
      Type Parameters:
      T - The target type.
      Parameters:
      value - The value to convert.
      Can be null (returns null).
      type - The target class.
      Returns:
      The converted value, or null if the input value was null.
    • apply

      public <T> SELF apply(Class<T> type, Consumer<T> apply)
      Applies a consumer to this builder if it's the specified type.
      Type Parameters:
      T - The expected type.
      Parameters:
      type - The expected type.
      Cannot be null.
      apply - The consumer to apply.
      Cannot be null.
      Returns:
      This object.
    • build

      public abstract ContextSession build()
      Build the object.
      Returns:
      The built object.
    • debug

      public SELF debug(Boolean value)
      Debug mode.

      Enables the following additional information during parsing:

      • When bean setters throws exceptions, the exception includes the object stack information in order to determine how that method was invoked.

      If not specified, defaults to Context.Builder.debug().

      See Also:
      Parameters:
      value - The new value for this property.
      If null, defaults to Context.isDebug().
      Returns:
      This object.
    • properties

      public SELF properties(Map<String,Object> value)
      Session properties.

      Session properties are generic key-value pairs that can be passed through the session and made available to any customized serializers/parsers or swaps.

      Parameters:
      value - The new value for this property.
      Cannot be null.
      Returns:
      This object.
    • property

      public SELF property(String key, Object value)
      Adds a property to this session.

      If the key matches a known session property (e.g. "debug" or "ContextSession.debug"), the value is converted via BasicConverter and routed to the corresponding typed setter. Unknown keys are stored in the raw session properties map.

      Parameters:
      key - The property key.
      Cannot be null.
      value - The property value.
      Can be null (resets typed properties to their default; removes raw properties).
      Returns:
      This object.
    • unmodifiable

      public SELF unmodifiable()
      Create an unmodifiable session.

      The created ContextSession object will be unmodifiable which makes it suitable for caching and reuse.

      Returns:
      This object.