Apama Documentation : Release Notes : What's New in Apama 5.0 : Event parser usability/type-safety improvements
Event parser usability/type-safety improvements
Apama's event parser library for Java has been improved to leverage Java generics and varargs to make it easier to use, and to provide automatic compile-time type safety for client applications that use the newly introduced generic methods and type parameters. The changes are:
*Field and FieldType now have a generic type parameter. This means that the compiler can assist with checking field types and eliminates the need for lots of type casts. The type parameter indicates the Java type used to represent field values, for example, for a sequence of integers the type parameter would be List<Long>.
Note, this change will not break existing code, but will cause warnings until the generic parameters are added to the caller's code. You can also add the Java annotation @SuppressWarnings("unchecked") to suppress specific compiler warnings.
*Added new getField and setField method overloadings. These methods accept either a Field<T>, or a field name and FieldType<T> parameter. With this change, the methods take advantage of the generic type information to enforce correct parameter and return types at compile-time.
Note, you can still use the old getField(fieldName) and setField(fieldName) methods to maintain backwards compatibility or if you are writing totally generic code that does not know what event types it is dealing with.
*The event parser library now explicitly prevents setting or getting null field values when using the new getField and setField methods. This simplifies coding and ensures you get a helpful message instead of a NullPointerException when getting a field value that was not assigned.
*The event parser library supports method chaining in setField to allow "fluent" coding style, allows fully initializing an event instance without needing to assign it to a temporary variable
*Added FieldType.newField(), DictionaryFieldType.type(), and SequenceFieldType.type() helper methods. These methods avoid the need to duplicate the generic type parameters on the RHS (as well as the LHS) when constructing fields and types. Using fieldType.newField(name)saves time and effort as compared to using new Field<type parameter>(name, fieldType).
*Use varargs for EventType(fields) to produce shorter code
*Introduce a new, optional varargs parameter to the EventParser constructor to simplify the typical need to initialize the event parser with a set of event types on startup
*The Javadoc documentation has been updated and now contains an example that illustrates the new behavior of the EventParser class
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback