Class ChoiceDefinition

All Implemented Interfaces:
org.apache.camel.CamelContextAware, org.apache.camel.LineNumberAware, Block, CopyableDefinition<ProcessorDefinition>, DisabledAwareDefinition, org.apache.camel.NamedNode, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.HasId, org.apache.camel.spi.IdAware

@Metadata(label="eip,routing") public class ChoiceDefinition extends NoOutputDefinition<ChoiceDefinition>
Route messages based on a series of predicates
  • Constructor Details

    • ChoiceDefinition

      public ChoiceDefinition()
    • ChoiceDefinition

      protected ChoiceDefinition(ChoiceDefinition source)
  • Method Details

    • copyDefinition

      public ChoiceDefinition copyDefinition()
      Description copied from interface: CopyableDefinition
      Makes a copy of this definition.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getPrecondition

      public String getPrecondition()
    • setPrecondition

      public void setPrecondition(String precondition)
      Indicates whether this Choice EIP is in precondition mode or not. If so its branches (when/otherwise) are evaluated during startup to keep at runtime only the branch that matched.
    • addOutput

      public void addOutput(ProcessorDefinition<?> output)
      Description copied from interface: Block
      Adds the given definition as output to this block
      Specified by:
      addOutput in interface Block
      Overrides:
      addOutput in class ProcessorDefinition<ChoiceDefinition>
      Parameters:
      output - the processor definition
    • addOutput

      public void addOutput(WhenDefinition when)
    • addOutput

      public void addOutput(OtherwiseDefinition other)
    • disabled

      public ChoiceDefinition disabled(String disabled)
      Whether to disable this EIP from the route during build time. Once an EIP has been disabled then it cannot be enabled later at runtime.
      Overrides:
      disabled in class ProcessorDefinition<ChoiceDefinition>
    • precondition

      public ChoiceDefinition precondition()
      Indicates that this Choice EIP is in precondition mode, its branches (when/otherwise) are then evaluated during startup to keep at runtime only the branch that matched.
      Returns:
      the builder
    • precondition

      public ChoiceDefinition precondition(boolean precondition)
      Indicates whether this Choice EIP is in precondition mode or not. If so its branches (when/otherwise) are evaluated during startup to keep at runtime only the branch that matched.
      Parameters:
      precondition - the flag indicating if it is in precondition mode or not.
      Returns:
      the builder
    • when

      public ChoiceDefinition when(@AsPredicate org.apache.camel.Predicate predicate)
      Sets the predicate for the when node
      Parameters:
      predicate - the predicate
      Returns:
      the builder
    • when

      @AsPredicate public ExpressionClause<ChoiceDefinition> when()
      Creates an expression for the when node
      Returns:
      expression to be used as builder to configure the when node
    • otherwise

      public ChoiceDefinition otherwise()
      Sets the otherwise node
      Returns:
      the builder
    • setId

      public void setId(String id)
      Description copied from class: OptionalIdentifiedDefinition
      Sets the id of this node
      Specified by:
      setId in interface org.apache.camel.spi.IdAware
      Overrides:
      setId in class OptionalIdentifiedDefinition<ChoiceDefinition>
    • getOutputs

      public List<ProcessorDefinition<?>> getOutputs()
      Overrides:
      getOutputs in class NoOutputDefinition<ChoiceDefinition>
    • getShortName

      public String getShortName()
    • getLabel

      public String getLabel()
      Description copied from class: ProcessorDefinition
      Returns a label to describe this node such as the expression if some kind of expression node
      Specified by:
      getLabel in interface org.apache.camel.NamedNode
      Overrides:
      getLabel in class ProcessorDefinition<ChoiceDefinition>
    • getWhenClauses

      public List<WhenDefinition> getWhenClauses()
    • setWhenClauses

      public void setWhenClauses(List<WhenDefinition> whenClauses)
      Sets the when nodes
    • getOtherwise

      public OtherwiseDefinition getOtherwise()
    • setOtherwise

      public void setOtherwise(OtherwiseDefinition otherwise)
    • preCreateProcessor

      public void preCreateProcessor()
      Description copied from class: ProcessorDefinition
      Strategy to execute any custom logic before the Processor is created.
      Overrides:
      preCreateProcessor in class ProcessorDefinition<ChoiceDefinition>