A BooleanManager is a FormatManager that provides services for Boolean objects.
| 28 | * objects. |
| 29 | */ |
| 30 | public class BooleanManager implements FormatManager<Boolean> |
| 31 | { |
| 32 | |
| 33 | /** |
| 34 | * Converts the given String to an object of the type processed by this |
| 35 | * FormatManager. |
| 36 | */ |
| 37 | @Override |
| 38 | public Boolean convert(String s) |
| 39 | { |
| 40 | if ("true".equalsIgnoreCase(s)) |
| 41 | { |
| 42 | return Boolean.TRUE; |
| 43 | } |
| 44 | else if ("false".equalsIgnoreCase(s)) |
| 45 | { |
| 46 | return Boolean.FALSE; |
| 47 | } |
| 48 | throw new IllegalArgumentException("Did not understand " + s |
| 49 | + " as a Boolean value"); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Converts the given String to an Indirect containing an object of the type |
| 54 | * processed by this FormatManager. |
| 55 | */ |
| 56 | @Override |
| 57 | public Indirect<Boolean> convertIndirect(String s) |
| 58 | { |
| 59 | return new BasicIndirect<>(this, convert(s)); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * "Unconverts" the object (converts the object to a "serializable" String |
| 64 | * format that can be reinterpreted by the convert* methods). |
| 65 | */ |
| 66 | @Override |
| 67 | public String unconvert(Boolean s) |
| 68 | { |
| 69 | return s.toString(); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * The Class that this FormatManager can convert or unconvert. |
| 74 | */ |
| 75 | @Override |
| 76 | public Class<Boolean> getManagedClass() |
| 77 | { |
| 78 | return Boolean.class; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * The String used to refer to this format in files like the variable |
| 83 | * definition file. |
| 84 | */ |
| 85 | @Override |
| 86 | public String getIdentifierType() |
| 87 | { |
nothing calls this directly
no outgoing calls
no test coverage detected