@Test public void testNormalEnum() { final String input = "NORMAL"; assertEquals(TestEnum.NORMAL, processor.execute(input, ANONYMOUS_CSVCONTEXT)); assertEquals(TestEnum.NORMAL, processorChain.execute(input, ANONYMOUS_CSVCONTEXT)); assertEquals(TestEnum.NORMAL, ignoreCaseProcessor.execute(input, ANONYMOUS_CSVCONTEXT)); assertEquals(TestEnum.NORMAL, ignoreCaseProcessorChain.execute(input, ANONYMOUS_CSVCONTEXT)); }
public Object execute(final Object value, final CsvContext context) { validateInputNotNull(value, context); final String inputString = value.toString(); for( final Enum<?> enumConstant : enumClass.getEnumConstants() ) { String constantName = enumConstant.name(); if( ignoreCase ? constantName.equalsIgnoreCase(inputString) : constantName.equals(inputString) ) { return enumConstant; } } throw new SuperCsvCellProcessorException(String.format("'%s' could not be parsed as a enum of type %s", value, enumClass.getName()), context, this); }
ParseEnum extends CellProcessorAdaptor implements StringCellProcessor { public Object execute(final Object value, final CsvContext context) { validateInputNotNull(value, context); final String inputString = value.toString(); for( final Enum<?> enumConstant : enumClass.getEnumConstants() ) { String constantName = enumConstant.name(); if( ignoreCase ? constantName.equalsIgnoreCase(inputString) : constantName.equals(inputString) ) { return enumConstant; } } throw new SuperCsvCellProcessorException(String.format("'%s' could not be parsed as a enum of type %s", value, enumClass.getName()), context, this); } }
ParseEnum extends CellProcessorAdaptor implements StringCellProcessor { public Object execute(final Object value, final CsvContext context) { validateInputNotNull(value, context); final String inputString = value.toString(); for( final Enum<?> enumConstant : enumClass.getEnumConstants() ) { String constantName = enumConstant.name(); if( ignoreCase ? constantName.equalsIgnoreCase(inputString) : constantName.equals(inputString) ) { return enumConstant; } } throw new SuperCsvCellProcessorException(String.format("'%s' could not be parsed as a enum of type %s", value, enumClass.getName()), context, this); } <T extends Enum<?>> ParseEnum(final Class<T> enumClass); <T extends Enum<?>> ParseEnum(final Class<T> enumClass, final boolean ignoreCase); <T extends Enum<?>> ParseEnum(final Class<T> enumClass, final CellProcessor next); <T extends Enum<?>> ParseEnum(final Class<T> enumClass, final boolean ignoreCase, final CellProcessor next); }
ParseEnum extends CellProcessorAdaptor implements StringCellProcessor { public Object execute(final Object value, final CsvContext context) { validateInputNotNull(value, context); final String inputString = value.toString(); for( final Enum<?> enumConstant : enumClass.getEnumConstants() ) { String constantName = enumConstant.name(); if( ignoreCase ? constantName.equalsIgnoreCase(inputString) : constantName.equals(inputString) ) { return enumConstant; } } throw new SuperCsvCellProcessorException(String.format("'%s' could not be parsed as a enum of type %s", value, enumClass.getName()), context, this); } <T extends Enum<?>> ParseEnum(final Class<T> enumClass); <T extends Enum<?>> ParseEnum(final Class<T> enumClass, final boolean ignoreCase); <T extends Enum<?>> ParseEnum(final Class<T> enumClass, final CellProcessor next); <T extends Enum<?>> ParseEnum(final Class<T> enumClass, final boolean ignoreCase, final CellProcessor next); Object execute(final Object value, final CsvContext context); }
ParseEnum extends CellProcessorAdaptor implements StringCellProcessor { public Object execute(final Object value, final CsvContext context) { validateInputNotNull(value, context); final String inputString = value.toString(); for( final Enum<?> enumConstant : enumClass.getEnumConstants() ) { String constantName = enumConstant.name(); if( ignoreCase ? constantName.equalsIgnoreCase(inputString) : constantName.equals(inputString) ) { return enumConstant; } } throw new SuperCsvCellProcessorException(String.format("'%s' could not be parsed as a enum of type %s", value, enumClass.getName()), context, this); } <T extends Enum<?>> ParseEnum(final Class<T> enumClass); <T extends Enum<?>> ParseEnum(final Class<T> enumClass, final boolean ignoreCase); <T extends Enum<?>> ParseEnum(final Class<T> enumClass, final CellProcessor next); <T extends Enum<?>> ParseEnum(final Class<T> enumClass, final boolean ignoreCase, final CellProcessor next); Object execute(final Object value, final CsvContext context);  }