001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau;
014
015import java.util.*;
016
017import org.apache.juneau.http.*;
018import org.apache.juneau.httppart.*;
019
020/**
021 * Runtime arguments common to all bean, serializer, and parser sessions.
022 */
023public class BeanSessionArgs extends SessionArgs {
024
025   /**
026    * Default empty session arguments.
027    */
028   public static final BeanSessionArgs DEFAULT = new BeanSessionArgs();
029
030   Locale locale;
031   TimeZone timeZone;
032   MediaType mediaType;
033   Boolean debug;
034   HttpPartSchema schema;
035
036   /**
037    * Constructor
038    */
039   public BeanSessionArgs() {}
040
041   /**
042    * Constructor.
043    *
044    * @param properties
045    *    Session-level properties.
046    *    <br>These override context-level properties.
047    *    <br>Can be <jk>null</jk>.
048    * @param locale
049    *    The session locale.
050    *    <br>If <jk>null</jk>, then the locale defined on the context is used.
051    * @param timeZone
052    *    The session timezone.
053    *    <br>If <jk>null</jk>, then the timezone defined on the context is used.
054    * @param mediaType
055    *    The session media type (e.g. <js>"application/json"</js>).
056    *    <br>Can be <jk>null</jk>.
057    * @param schema
058    *    The part schema for the serialized part.
059    *    <br>Can be <jk>null</jk>.
060    * @param debug
061    *    Enable debug mode for this session.
062    *    <br>Can be <jk>null</jk> to use the debug setting on the bean context..
063    */
064   public BeanSessionArgs(ObjectMap properties, Locale locale, TimeZone timeZone, MediaType mediaType, HttpPartSchema schema, Boolean debug) {
065      super(properties);
066      this.locale = locale;
067      this.timeZone = timeZone;
068      this.mediaType = mediaType;
069      this.schema = schema;
070      this.debug = debug;
071   }
072
073   /**
074    * The session locale.
075    *
076    * @param locale
077    *    The session locale.
078    *    <br>If <jk>null</jk>, then the locale defined on the context is used.
079    * @return This object (for method chaining).
080    */
081   public BeanSessionArgs locale(Locale locale) {
082      this.locale = locale;
083      return this;
084   }
085
086   /**
087    * The session timezone.
088    *
089    * @param timeZone
090    *    The session timezone.
091    *    <br>If <jk>null</jk>, then the timezone defined on the context is used.
092    * @return This object (for method chaining).
093    */
094   public BeanSessionArgs timeZone(TimeZone timeZone) {
095      this.timeZone = timeZone;
096      return this;
097   }
098
099   /**
100    * The session media type.
101    *
102    * @param mediaType
103    *    The session media type (e.g. <js>"application/json"</js>).
104    *    <br>Can be <jk>null</jk>.
105    * @return This object (for method chaining).
106    */
107   public BeanSessionArgs mediaType(MediaType mediaType) {
108      this.mediaType = mediaType;
109      return this;
110   }
111
112   /**
113    * Debug mode.
114    *
115    * @param debug
116    *    Debug mode flag.
117    *    <br>Can be <jk>null</jk>.
118    * @return This object (for method chaining).
119    */
120   public BeanSessionArgs debug(Boolean debug) {
121      this.debug = debug;
122      return this;
123   }
124
125   @Override /* SessionArgs */
126   public BeanSessionArgs properties(ObjectMap properties) {
127      super.properties(properties);
128      return this;
129   }
130
131   /**
132    * @deprecated Use {@link #BeanSessionArgs(ObjectMap, Locale, TimeZone, MediaType, HttpPartSchema, Boolean)}
133    */
134   @SuppressWarnings("javadoc")
135   @Deprecated
136   public BeanSessionArgs(ObjectMap properties, Locale locale, TimeZone timeZone, MediaType mediaType) {
137      super(properties);
138      this.locale = locale;
139      this.timeZone = timeZone;
140      this.mediaType = mediaType;
141   }
142}