-
Enhancement
-
Resolution: Done
-
Major
-
20.0.0.Beta5
-
None
When constructing a PersistentResourceXMLDescription, it is very convenient to use Streams, whether to filter a set of attributes that do not apply to a given schema version, or to combine multiple sets of attributes.
e.g.
PersistentResourceXMLDescriptionBuilder builder = builder(PATH_ELEMENT); Stream<? extends AttributeDefinition> attributes = Stream.concat(MyResourceDefinition.ATTRIBUTES.stream(), MyParentResourceDefinition.ATTRIBUTES.stream()); if (!schema.since(Schema.VERSION_2)) { attributes = attributes.filter(Predicate.not(Set.of(MyResourceDefinition.FOO, MyResourceDefinition.BAR)::contains)); } attributes::forEach(builder:addAttribute);
However, in order to use this pattern fluently, most implementations will end up with the same static method:
static PersistentResourceXMLDescriptionBuilder addAttributes(PersistentResourceXMLDescriptionBuilder builder, Stream<? extends AttributeDefinition> attributes) { attributes::forEach(builder::addAttribute); return builder; }
Adding a stream-based addAttributes(...) method avoids the need for implementors to duplicate this method.
- blocks
-
WFLY-17611 Leverage stream-based PersistentResourceXMLDescription builder methods.
- Closed