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.csv;
014
015import java.lang.annotation.*;
016import java.lang.reflect.*;
017import java.nio.charset.*;
018import java.util.*;
019import java.util.concurrent.*;
020
021import org.apache.juneau.*;
022import org.apache.juneau.internal.*;
023import org.apache.juneau.serializer.*;
024import org.apache.juneau.utils.*;
025
026/**
027 * TODO - Work in progress.  CSV serializer.
028 *
029 * <h5 class='section'>Notes:</h5><ul>
030 *    <li class='note'>This class is thread safe and reusable.
031 * </ul>
032 *
033 * <h5 class='section'>See Also:</h5><ul>
034
035 * </ul>
036 */
037public final class CsvSerializer extends WriterSerializer implements CsvMetaProvider {
038
039   //-------------------------------------------------------------------------------------------------------------------
040   // Static
041   //-------------------------------------------------------------------------------------------------------------------
042
043   /** Default serializer, all default settings.*/
044   public static final CsvSerializer DEFAULT = new CsvSerializer(create());
045
046   /**
047    * Creates a new builder for this object.
048    *
049    * @return A new builder.
050    */
051   public static Builder create() {
052      return new Builder();
053   }
054
055   //-------------------------------------------------------------------------------------------------------------------
056   // Builder
057   //-------------------------------------------------------------------------------------------------------------------
058
059   /**
060    * Builder class.
061    */
062   @FluentSetters
063   public static class Builder extends WriterSerializer.Builder {
064
065      private static final Cache<HashKey,CsvSerializer> CACHE = Cache.of(HashKey.class, CsvSerializer.class).build();
066
067      /**
068       * Constructor, default settings.
069       */
070      protected Builder() {
071         super();
072         produces("text/csv");
073      }
074
075      /**
076       * Copy constructor.
077       *
078       * @param copyFrom The bean to copy from.
079       */
080      protected Builder(CsvSerializer copyFrom) {
081         super(copyFrom);
082      }
083
084      /**
085       * Copy constructor.
086       *
087       * @param copyFrom The builder to copy from.
088       */
089      protected Builder(Builder copyFrom) {
090         super(copyFrom);
091      }
092
093      @Override /* Context.Builder */
094      public Builder copy() {
095         return new Builder(this);
096      }
097
098      @Override /* Context.Builder */
099      public CsvSerializer build() {
100         return cache(CACHE).build(CsvSerializer.class);
101      }
102
103      @Override /* Context.Builder */
104      public HashKey hashKey() {
105         return super.hashKey();
106      }
107
108      //-----------------------------------------------------------------------------------------------------------------
109      // Properties
110      //-----------------------------------------------------------------------------------------------------------------
111
112      // <FluentSetters>
113
114      @Override /* GENERATED - org.apache.juneau.Context.Builder */
115      public Builder annotations(Annotation...values) {
116         super.annotations(values);
117         return this;
118      }
119
120      @Override /* GENERATED - org.apache.juneau.Context.Builder */
121      public Builder apply(AnnotationWorkList work) {
122         super.apply(work);
123         return this;
124      }
125
126      @Override /* GENERATED - org.apache.juneau.Context.Builder */
127      public Builder applyAnnotations(java.lang.Class<?>...fromClasses) {
128         super.applyAnnotations(fromClasses);
129         return this;
130      }
131
132      @Override /* GENERATED - org.apache.juneau.Context.Builder */
133      public Builder applyAnnotations(Method...fromMethods) {
134         super.applyAnnotations(fromMethods);
135         return this;
136      }
137
138      @Override /* GENERATED - org.apache.juneau.Context.Builder */
139      public Builder cache(Cache<HashKey,? extends org.apache.juneau.Context> value) {
140         super.cache(value);
141         return this;
142      }
143
144      @Override /* GENERATED - org.apache.juneau.Context.Builder */
145      public Builder debug() {
146         super.debug();
147         return this;
148      }
149
150      @Override /* GENERATED - org.apache.juneau.Context.Builder */
151      public Builder debug(boolean value) {
152         super.debug(value);
153         return this;
154      }
155
156      @Override /* GENERATED - org.apache.juneau.Context.Builder */
157      public Builder impl(Context value) {
158         super.impl(value);
159         return this;
160      }
161
162      @Override /* GENERATED - org.apache.juneau.Context.Builder */
163      public Builder type(Class<? extends org.apache.juneau.Context> value) {
164         super.type(value);
165         return this;
166      }
167
168      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
169      public Builder beanClassVisibility(Visibility value) {
170         super.beanClassVisibility(value);
171         return this;
172      }
173
174      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
175      public Builder beanConstructorVisibility(Visibility value) {
176         super.beanConstructorVisibility(value);
177         return this;
178      }
179
180      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
181      public Builder beanContext(BeanContext value) {
182         super.beanContext(value);
183         return this;
184      }
185
186      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
187      public Builder beanContext(BeanContext.Builder value) {
188         super.beanContext(value);
189         return this;
190      }
191
192      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
193      public Builder beanDictionary(java.lang.Class<?>...values) {
194         super.beanDictionary(values);
195         return this;
196      }
197
198      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
199      public Builder beanFieldVisibility(Visibility value) {
200         super.beanFieldVisibility(value);
201         return this;
202      }
203
204      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
205      public Builder beanInterceptor(Class<?> on, Class<? extends org.apache.juneau.swap.BeanInterceptor<?>> value) {
206         super.beanInterceptor(on, value);
207         return this;
208      }
209
210      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
211      public Builder beanMapPutReturnsOldValue() {
212         super.beanMapPutReturnsOldValue();
213         return this;
214      }
215
216      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
217      public Builder beanMethodVisibility(Visibility value) {
218         super.beanMethodVisibility(value);
219         return this;
220      }
221
222      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
223      public Builder beanProperties(Map<String,Object> values) {
224         super.beanProperties(values);
225         return this;
226      }
227
228      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
229      public Builder beanProperties(Class<?> beanClass, String properties) {
230         super.beanProperties(beanClass, properties);
231         return this;
232      }
233
234      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
235      public Builder beanProperties(String beanClassName, String properties) {
236         super.beanProperties(beanClassName, properties);
237         return this;
238      }
239
240      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
241      public Builder beanPropertiesExcludes(Map<String,Object> values) {
242         super.beanPropertiesExcludes(values);
243         return this;
244      }
245
246      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
247      public Builder beanPropertiesExcludes(Class<?> beanClass, String properties) {
248         super.beanPropertiesExcludes(beanClass, properties);
249         return this;
250      }
251
252      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
253      public Builder beanPropertiesExcludes(String beanClassName, String properties) {
254         super.beanPropertiesExcludes(beanClassName, properties);
255         return this;
256      }
257
258      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
259      public Builder beanPropertiesReadOnly(Map<String,Object> values) {
260         super.beanPropertiesReadOnly(values);
261         return this;
262      }
263
264      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
265      public Builder beanPropertiesReadOnly(Class<?> beanClass, String properties) {
266         super.beanPropertiesReadOnly(beanClass, properties);
267         return this;
268      }
269
270      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
271      public Builder beanPropertiesReadOnly(String beanClassName, String properties) {
272         super.beanPropertiesReadOnly(beanClassName, properties);
273         return this;
274      }
275
276      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
277      public Builder beanPropertiesWriteOnly(Map<String,Object> values) {
278         super.beanPropertiesWriteOnly(values);
279         return this;
280      }
281
282      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
283      public Builder beanPropertiesWriteOnly(Class<?> beanClass, String properties) {
284         super.beanPropertiesWriteOnly(beanClass, properties);
285         return this;
286      }
287
288      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
289      public Builder beanPropertiesWriteOnly(String beanClassName, String properties) {
290         super.beanPropertiesWriteOnly(beanClassName, properties);
291         return this;
292      }
293
294      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
295      public Builder beansRequireDefaultConstructor() {
296         super.beansRequireDefaultConstructor();
297         return this;
298      }
299
300      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
301      public Builder beansRequireSerializable() {
302         super.beansRequireSerializable();
303         return this;
304      }
305
306      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
307      public Builder beansRequireSettersForGetters() {
308         super.beansRequireSettersForGetters();
309         return this;
310      }
311
312      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
313      public Builder dictionaryOn(Class<?> on, java.lang.Class<?>...values) {
314         super.dictionaryOn(on, values);
315         return this;
316      }
317
318      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
319      public Builder disableBeansRequireSomeProperties() {
320         super.disableBeansRequireSomeProperties();
321         return this;
322      }
323
324      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
325      public Builder disableIgnoreMissingSetters() {
326         super.disableIgnoreMissingSetters();
327         return this;
328      }
329
330      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
331      public Builder disableIgnoreTransientFields() {
332         super.disableIgnoreTransientFields();
333         return this;
334      }
335
336      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
337      public Builder disableIgnoreUnknownNullBeanProperties() {
338         super.disableIgnoreUnknownNullBeanProperties();
339         return this;
340      }
341
342      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
343      public Builder disableInterfaceProxies() {
344         super.disableInterfaceProxies();
345         return this;
346      }
347
348      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
349      public <T> Builder example(Class<T> pojoClass, T o) {
350         super.example(pojoClass, o);
351         return this;
352      }
353
354      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
355      public <T> Builder example(Class<T> pojoClass, String json) {
356         super.example(pojoClass, json);
357         return this;
358      }
359
360      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
361      public Builder findFluentSetters() {
362         super.findFluentSetters();
363         return this;
364      }
365
366      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
367      public Builder findFluentSetters(Class<?> on) {
368         super.findFluentSetters(on);
369         return this;
370      }
371
372      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
373      public Builder ignoreInvocationExceptionsOnGetters() {
374         super.ignoreInvocationExceptionsOnGetters();
375         return this;
376      }
377
378      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
379      public Builder ignoreInvocationExceptionsOnSetters() {
380         super.ignoreInvocationExceptionsOnSetters();
381         return this;
382      }
383
384      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
385      public Builder ignoreUnknownBeanProperties() {
386         super.ignoreUnknownBeanProperties();
387         return this;
388      }
389
390      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
391      public Builder ignoreUnknownEnumValues() {
392         super.ignoreUnknownEnumValues();
393         return this;
394      }
395
396      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
397      public Builder implClass(Class<?> interfaceClass, Class<?> implClass) {
398         super.implClass(interfaceClass, implClass);
399         return this;
400      }
401
402      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
403      public Builder implClasses(Map<Class<?>,Class<?>> values) {
404         super.implClasses(values);
405         return this;
406      }
407
408      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
409      public Builder interfaceClass(Class<?> on, Class<?> value) {
410         super.interfaceClass(on, value);
411         return this;
412      }
413
414      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
415      public Builder interfaces(java.lang.Class<?>...value) {
416         super.interfaces(value);
417         return this;
418      }
419
420      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
421      public Builder locale(Locale value) {
422         super.locale(value);
423         return this;
424      }
425
426      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
427      public Builder mediaType(MediaType value) {
428         super.mediaType(value);
429         return this;
430      }
431
432      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
433      public Builder notBeanClasses(java.lang.Class<?>...values) {
434         super.notBeanClasses(values);
435         return this;
436      }
437
438      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
439      public Builder notBeanPackages(String...values) {
440         super.notBeanPackages(values);
441         return this;
442      }
443
444      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
445      public Builder propertyNamer(Class<? extends org.apache.juneau.PropertyNamer> value) {
446         super.propertyNamer(value);
447         return this;
448      }
449
450      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
451      public Builder propertyNamer(Class<?> on, Class<? extends org.apache.juneau.PropertyNamer> value) {
452         super.propertyNamer(on, value);
453         return this;
454      }
455
456      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
457      public Builder sortProperties() {
458         super.sortProperties();
459         return this;
460      }
461
462      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
463      public Builder sortProperties(java.lang.Class<?>...on) {
464         super.sortProperties(on);
465         return this;
466      }
467
468      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
469      public Builder stopClass(Class<?> on, Class<?> value) {
470         super.stopClass(on, value);
471         return this;
472      }
473
474      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
475      public <T, S> Builder swap(Class<T> normalClass, Class<S> swappedClass, ThrowingFunction<T,S> swapFunction) {
476         super.swap(normalClass, swappedClass, swapFunction);
477         return this;
478      }
479
480      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
481      public <T, S> Builder swap(Class<T> normalClass, Class<S> swappedClass, ThrowingFunction<T,S> swapFunction, ThrowingFunction<S,T> unswapFunction) {
482         super.swap(normalClass, swappedClass, swapFunction, unswapFunction);
483         return this;
484      }
485
486      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
487      public Builder swaps(java.lang.Class<?>...values) {
488         super.swaps(values);
489         return this;
490      }
491
492      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
493      public Builder timeZone(TimeZone value) {
494         super.timeZone(value);
495         return this;
496      }
497
498      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
499      public Builder typeName(Class<?> on, String value) {
500         super.typeName(on, value);
501         return this;
502      }
503
504      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
505      public Builder typePropertyName(String value) {
506         super.typePropertyName(value);
507         return this;
508      }
509
510      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
511      public Builder typePropertyName(Class<?> on, String value) {
512         super.typePropertyName(on, value);
513         return this;
514      }
515
516      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
517      public Builder useEnumNames() {
518         super.useEnumNames();
519         return this;
520      }
521
522      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
523      public Builder useJavaBeanIntrospector() {
524         super.useJavaBeanIntrospector();
525         return this;
526      }
527
528      @Override /* GENERATED - org.apache.juneau.BeanTraverseContext.Builder */
529      public Builder detectRecursions() {
530         super.detectRecursions();
531         return this;
532      }
533
534      @Override /* GENERATED - org.apache.juneau.BeanTraverseContext.Builder */
535      public Builder detectRecursions(boolean value) {
536         super.detectRecursions(value);
537         return this;
538      }
539
540      @Override /* GENERATED - org.apache.juneau.BeanTraverseContext.Builder */
541      public Builder ignoreRecursions() {
542         super.ignoreRecursions();
543         return this;
544      }
545
546      @Override /* GENERATED - org.apache.juneau.BeanTraverseContext.Builder */
547      public Builder ignoreRecursions(boolean value) {
548         super.ignoreRecursions(value);
549         return this;
550      }
551
552      @Override /* GENERATED - org.apache.juneau.BeanTraverseContext.Builder */
553      public Builder initialDepth(int value) {
554         super.initialDepth(value);
555         return this;
556      }
557
558      @Override /* GENERATED - org.apache.juneau.BeanTraverseContext.Builder */
559      public Builder maxDepth(int value) {
560         super.maxDepth(value);
561         return this;
562      }
563
564      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
565      public Builder accept(String value) {
566         super.accept(value);
567         return this;
568      }
569
570      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
571      public Builder addBeanTypes() {
572         super.addBeanTypes();
573         return this;
574      }
575
576      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
577      public Builder addBeanTypes(boolean value) {
578         super.addBeanTypes(value);
579         return this;
580      }
581
582      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
583      public Builder addRootType() {
584         super.addRootType();
585         return this;
586      }
587
588      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
589      public Builder addRootType(boolean value) {
590         super.addRootType(value);
591         return this;
592      }
593
594      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
595      public Builder keepNullProperties() {
596         super.keepNullProperties();
597         return this;
598      }
599
600      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
601      public Builder keepNullProperties(boolean value) {
602         super.keepNullProperties(value);
603         return this;
604      }
605
606      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
607      public Builder listener(Class<? extends org.apache.juneau.serializer.SerializerListener> value) {
608         super.listener(value);
609         return this;
610      }
611
612      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
613      public Builder produces(String value) {
614         super.produces(value);
615         return this;
616      }
617
618      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
619      public Builder sortCollections() {
620         super.sortCollections();
621         return this;
622      }
623
624      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
625      public Builder sortCollections(boolean value) {
626         super.sortCollections(value);
627         return this;
628      }
629
630      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
631      public Builder sortMaps() {
632         super.sortMaps();
633         return this;
634      }
635
636      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
637      public Builder sortMaps(boolean value) {
638         super.sortMaps(value);
639         return this;
640      }
641
642      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
643      public Builder trimEmptyCollections() {
644         super.trimEmptyCollections();
645         return this;
646      }
647
648      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
649      public Builder trimEmptyCollections(boolean value) {
650         super.trimEmptyCollections(value);
651         return this;
652      }
653
654      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
655      public Builder trimEmptyMaps() {
656         super.trimEmptyMaps();
657         return this;
658      }
659
660      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
661      public Builder trimEmptyMaps(boolean value) {
662         super.trimEmptyMaps(value);
663         return this;
664      }
665
666      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
667      public Builder trimStrings() {
668         super.trimStrings();
669         return this;
670      }
671
672      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
673      public Builder trimStrings(boolean value) {
674         super.trimStrings(value);
675         return this;
676      }
677
678      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
679      public Builder uriContext(UriContext value) {
680         super.uriContext(value);
681         return this;
682      }
683
684      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
685      public Builder uriRelativity(UriRelativity value) {
686         super.uriRelativity(value);
687         return this;
688      }
689
690      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
691      public Builder uriResolution(UriResolution value) {
692         super.uriResolution(value);
693         return this;
694      }
695
696      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
697      public Builder fileCharset(Charset value) {
698         super.fileCharset(value);
699         return this;
700      }
701
702      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
703      public Builder maxIndent(int value) {
704         super.maxIndent(value);
705         return this;
706      }
707
708      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
709      public Builder quoteChar(char value) {
710         super.quoteChar(value);
711         return this;
712      }
713
714      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
715      public Builder quoteCharOverride(char value) {
716         super.quoteCharOverride(value);
717         return this;
718      }
719
720      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
721      public Builder sq() {
722         super.sq();
723         return this;
724      }
725
726      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
727      public Builder streamCharset(Charset value) {
728         super.streamCharset(value);
729         return this;
730      }
731
732      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
733      public Builder useWhitespace() {
734         super.useWhitespace();
735         return this;
736      }
737
738      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
739      public Builder useWhitespace(boolean value) {
740         super.useWhitespace(value);
741         return this;
742      }
743
744      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
745      public Builder ws() {
746         super.ws();
747         return this;
748      }
749
750      // </FluentSetters>
751   }
752
753   //-------------------------------------------------------------------------------------------------------------------
754   // Instance
755   //-------------------------------------------------------------------------------------------------------------------
756
757   private final Map<ClassMeta<?>,CsvClassMeta> csvClassMetas = new ConcurrentHashMap<>();
758   private final Map<BeanPropertyMeta,CsvBeanPropertyMeta> csvBeanPropertyMetas = new ConcurrentHashMap<>();
759
760   /**
761    * Constructor.
762    *
763    * @param builder The builder for this object.
764    */
765   public CsvSerializer(Builder builder) {
766      super(builder);
767   }
768
769   @Override /* Context */
770   public Builder copy() {
771      return new Builder(this);
772   }
773
774   @Override /* Context */
775   public CsvSerializerSession.Builder createSession() {
776      return CsvSerializerSession.create(this);
777   }
778
779   @Override /* Context */
780   public CsvSerializerSession getSession() {
781      return createSession().build();
782   }
783
784   //-----------------------------------------------------------------------------------------------------------------
785   // Extended metadata
786   //-----------------------------------------------------------------------------------------------------------------
787
788   @Override /* CsvMetaProvider */
789   public CsvClassMeta getCsvClassMeta(ClassMeta<?> cm) {
790      CsvClassMeta m = csvClassMetas.get(cm);
791      if (m == null) {
792         m = new CsvClassMeta(cm, this);
793         csvClassMetas.put(cm, m);
794      }
795      return m;
796   }
797
798   @Override /* CsvMetaProvider */
799   public CsvBeanPropertyMeta getCsvBeanPropertyMeta(BeanPropertyMeta bpm) {
800      if (bpm == null)
801         return CsvBeanPropertyMeta.DEFAULT;
802      CsvBeanPropertyMeta m = csvBeanPropertyMetas.get(bpm);
803      if (m == null) {
804         m = new CsvBeanPropertyMeta(bpm.getDelegateFor(), this);
805         csvBeanPropertyMetas.put(bpm, m);
806      }
807      return m;
808   }
809}