aQute.bnd.build.model.conversions
Class EnumFormatter<E extends Enum<E>>

java.lang.Object
  extended by aQute.bnd.build.model.conversions.EnumFormatter<E>
Type Parameters:
E -
All Implemented Interfaces:
Converter<String,E>

public class EnumFormatter<E extends Enum<E>>
extends Object
implements Converter<String,E>

Formats an enum type. Outputs null when the value of the enum is equal to a default value.

Author:
Neil Bartlett

Method Summary
 String convert(E input)
           
static
<E extends Enum<E>>
EnumFormatter<E>
create(Class<E> enumType)
          Construct a new formatter with no default value, i.e.
static
<E extends Enum<E>>
EnumFormatter<E>
create(Class<E> enumType, E defaultValue)
          Construct a new formatter with the specified default value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static <E extends Enum<E>> EnumFormatter<E> create(Class<E> enumType)
Construct a new formatter with no default value, i.e. any non-null value of the enum will print that value.

Parameters:
enumType - The enum type.
Returns:

create

public static <E extends Enum<E>> EnumFormatter<E> create(Class<E> enumType,
                                                          E defaultValue)
Construct a new formatter with the specified default value.

Parameters:
enumType - The enum type.
defaultValue - The default value, which will never be output.
Returns:

convert

public String convert(E input)
               throws IllegalArgumentException
Specified by:
convert in interface Converter<String,E extends Enum<E>>
Throws:
IllegalArgumentException


Copyright © 2013 aQute SARL. All Rights Reserved.