Package com.norconex.commons.lang.xml.flow

# Class XmlFlow<T>

java.lang.Object
com.norconex.commons.lang.xml.flow.XmlFlow<T>

Type Parameters:
  `T` - type of the object to be submitted to the flow.

public final class XmlFlow<T> extends Object

Treats an XML block as being a mix of predicate and consumer classes to create an execution "flow". The XML syntax below can be used create conditional `Predicate` statements deciding whether to execute or not `Consumer` objects.

## XML Syntax

     <!-- Proceeds if condition is true. -->
     <if>
       <!--
         A single XML "condition" or "conditions" (i.e., condition group).
         A condition group accepts an operator. Example:
         -->
       <conditions operator="[AND|OR]">
         <!--
           Unless you have a default implementation configured, "condition"
           expects a "class" attribute pointing to a Predicate implementation.
           E.g.:
           -->
         <condition class="(a Predicate implementation)"/>
         <condition class="(a Predicate implementation)"/>
       </conditions>
       <then>
         <!--
           Holds one or more XML elements with a "class" attribute pointing to a
           Consumer implementation. Executed when above condition or condition
           group evaluates to true. Can also contain nested if/ifNot blocks.
           -->
       </then>
       <else>
         <!--
           Optional. Same as "then" above, but triggered if the condition
           evaluates to false. Can also contain nested if/ifNot blocks.
           -->
       </else>
     </if>

     <!-- Proceed if condition is false. -->
     <ifNot>
       <!-- Same as "if" tag -->
     </ifNot>

Since:
  2.0.0

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `DEFAULT_CONSUMERS_WRITE_TAG_NAME`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `XmlFlow()`
  `XmlFlow(Class<? extends XmlFlowConsumerAdapter<T>> consumerAdapter, Class<? extends XmlFlowPredicateAdapter<T>> predicateAdapter)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object o)`
  `Class<? extends XmlFlowConsumerAdapter<T>>`
  `getConsumerAdapter()`
  `Class<? extends XmlFlowPredicateAdapter<T>>`
  `getPredicateAdapter()`
  `int`
  `hashCode()`
  `Consumer<T>`
  `parse(Xml xml)`
  `String`
  `toString()`
  `void`
  `write(Xml xml, Consumer<T> consumer)`
  Writes a flow previously constructed by `parse(Xml)` to XML.

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### DEFAULT_CONSUMERS_WRITE_TAG_NAME

    public static final String DEFAULT_CONSUMERS_WRITE_TAG_NAME
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### XmlFlow

    public XmlFlow()

  - ### XmlFlow

    public XmlFlow(Class<? extends XmlFlowConsumerAdapter<T>> consumerAdapter, Class<? extends XmlFlowPredicateAdapter<T>> predicateAdapter)

- ## Method Details

  - ### getConsumerAdapter

    public Class<? extends XmlFlowConsumerAdapter<T>> getConsumerAdapter()

  - ### getPredicateAdapter

    public Class<? extends XmlFlowPredicateAdapter<T>> getPredicateAdapter()

  - ### parse

    public Consumer<T> parse(Xml xml)

  - ### write

    public void write(Xml xml, Consumer<T> consumer)
    Writes a flow previously constructed by `parse(Xml)` to XML.
    Parameters:
      `xml` - the XML to write to
      `consumer` - the consumer flow to write

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`