camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guillaume Nodet" <>
Subject Missing methods on ChoiceType and TryType
Date Fri, 07 Sep 2007 12:32:01 GMT
The ChoiceType and TryType overrides lots of methods from
ProcessorType so that the output (which is always this) can be of the
current type, thus having a fluent DSL ;-)
Unfortuntately, there are lots of methods missing on these classes.
So we have one solution which is to make sure they are all overriden
(with tall the maintenance burden).
Another solution is to make the ProcessorType a generic:

public abstract class ProcessorType<Type extends ProcessorType> {
   public Type to(String uri) {
        addOutput(new ToType(uri));
        return (Type) this;

Then, the ChoiceType would become

public class ChoiceType extends ProcessorType<ChoiceType> {

All the return type would be correct without the need to override them.
However the drawback is that ProcessorType becomes a generic, so at
some places, we need to write
like in the ProcessorType class:
   public abstract List<ProcessorType<?>> getOutputs();
and in all classes that override this method.

or force a type to specicy the generic used
   public class AggregatorType extends ExpressionNode<ProcessorType> {

Is does not seems to affect the other modules in any way, so I'm keen
on committing this patch.  Opinions ?

Guillaume Nodet

View raw message