View Javadoc
1   /*
2    * Copyright 2016 Andrew Rucker Jones.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.opencsv.bean.customconverter;
17  
18  /**
19   * This class converts common French representations of boolean values into a
20   * {@link Boolean}.
21   * This class also demonstrates how to localize booleans for any other language.
22   *
23   * @param <T> Type of the bean to be manipulated
24   * @param <I> Type of the index into multivalued fields
25   * 
26   * @author Andrew Rucker Jones
27   * @since 5.4
28   */
29  public class ConvertFrenchToBoolean<T, I> extends ConverterLanguageToBoolean<T, I> {
30  
31      /**
32       * Silence code style checker by adding a useless constructor.
33       */
34      public ConvertFrenchToBoolean() {
35      }
36  
37      private static final String VRAI = "vrai";
38      private static final String FAUX = "faux";
39      private static final String[] TRUE_STRINGS = {VRAI, "oui", "o", "1", "v"};
40      private static final String[] FALSE_STRINGS = {FAUX, "non", "n", "0", "f"};
41  
42      @Override
43      protected String getLocalizedTrue() { return VRAI; }
44  
45      @Override
46      protected String getLocalizedFalse() { return FAUX; }
47  
48      @Override
49      protected String[] getAllLocalizedTrueValues() { return TRUE_STRINGS; }
50  
51      @Override
52      protected String[] getAllLocalizedFalseValues() { return FALSE_STRINGS; }
53  }