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 German 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 3.8 28 */ 29 public class ConvertGermanToBoolean<T, I> extends ConverterLanguageToBoolean<T, I> { 30 31 private static final String WAHR = "wahr"; 32 private static final String FALSCH = "falsch"; 33 private static final String[] TRUE_STRINGS = {WAHR, "ja", "j", "1", "w"}; 34 private static final String[] FALSE_STRINGS = {FALSCH, "nein", "n", "0", "f"}; 35 36 /** 37 * Silence code style checker by adding a useless constructor. 38 */ 39 public ConvertGermanToBoolean() { 40 } 41 42 @Override 43 protected String getLocalizedTrue() { return WAHR; } 44 45 @Override 46 protected String getLocalizedFalse() { return FALSCH; } 47 48 @Override 49 protected String[] getAllLocalizedTrueValues() { return TRUE_STRINGS; } 50 51 @Override 52 protected String[] getAllLocalizedFalseValues() { return FALSE_STRINGS; } 53 }