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