SethiPandi opened a new pull request #49: URL: https://github.com/apache/commons-beanutils/pull/49
This updates some existing converters to the implementations referenced in https://github.com/apache/commons-beanutils/pull/47. I didn't bother moving code over if the only differences were [conditional checks](https://github.com/apache/deltaspike/pull/109/files#diff-63785c6a056b9caf8429e7ad1aa80c1d7f3ef308b0a7575a0668ae7f00742a2f), or [constructor parameters](https://github.com/apache/deltaspike/pull/109/files#diff-c915606a7619184f993de23365598c0305831363c9a53ec92129ef266af32631). All existing test cases still pass, and new ones have been added. **Character** Accepts hex input, to specify a character via its character code instead. Intended where there are concerns regarding the environment, such as system/file encoding between clients, applications, and servers. (I've worked somewhere before where we couldn't put £ or € in the source. ^-^') Original plan was to enforce single character Strings, or a hexadecimal integer only. Since a CharacterConverter already exists in this repo which allows multiple character Strings, I've kept that around but added the hexadecimal support on top. That means `0xA3` would return `£`, not `0`. Not sure if this is a good idea though as it may cause confusion along with allowing multiple character Strings. **Duration** Will now accept number of milliseconds if it can't parse the input as a Duration string. Intended to just be an easier way to define it rather than needing to know the Duration syntax. **Enum** Will now accept types to the normal `Enum` class, for example if assigning to `Enum`, it can accept input from `java.time.DayOfWeek#MONDAY` or `java.time.DayOfWeek.MONDAY` to get the constant `MONDAY` from the `DayOfWeek` enum type. Intended for cases where an enum is required, but not a specific type, or multiple types. My use case is having certain enums (such as states, actions, or categories of events) which are localized, in the language file; the key being full enum name which can be converted to an EnumMap at startup. (Might be a dumb idea, haven't really tested this yet... but implemented this part anyway.) **Instant** Can now convert Instants (another DateTime type). I wanted this to support numeric Strings (ie milliseconds as a String) as well but I didn't do this now. I'll explore the abstract DateTimeConverter more later. **Period** Will now accept a number of days if it can't parse the input as a Period string. Intended for the same reason as Duration. --- * I've updated test classes for the converters that this affects to JUnit 4. (ie `@Test` annotations, and no longer extending `TestCase`) * In tests I've updated the use of some deprecated methods to what is recommended instead. i.e. (`new Character()` → `Character.valueOf()`) (`new Character()` is deprecated from Java 9, but `Character.valueOf()` is already available, so figured I could just move it already.) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
