Class AttributeMessageBuilder

java.lang.Object
com.mayam.wf.mq.AttributeMessageBuilder

public class AttributeMessageBuilder extends Object
A builder for AttributeMap based MqMessage objects.
  @Inject Provider<AttributeMessageBuilder> builderProvider;
  ...

  MqMessage message =
    builderProvider.get()
      .subject(task)
      .highlight(AttributeSet.of(Attribute.TASK_STATE, Attribute.ASSET_SITE_ID))
      .build();
 
Author:
Markus Mårtensson
  • Constructor Details

    • AttributeMessageBuilder

      @Inject public AttributeMessageBuilder(javax.inject.Provider<MqMessage> msgProvider, javax.inject.Provider<AttributeMap> mapProvider, com.mayam.wf.attributes.server.AttributeMapMapper mapper)
  • Method Details

    • subject

      public AttributeMessageBuilder subject(AttributeMap subject)
      Specifies the subject AttributeMap described in the ContentTypes.ATTRIBUTES message, or the "after" of a before/after subject pair for a ContentTypes.ATTRIBUTE_PAIRS message.
      Parameters:
      subject - message subject.
      Returns:
      the builder for chaining purposes.
    • before

      public AttributeMessageBuilder before(AttributeMap before)
      Specifies the "before" of a before/after subject pair for a ContentTypes.ATTRIBUTE_PAIRS message.
      Parameters:
      before - message "before" subject.
      Returns:
      the builder for chaining purposes.
    • include

      public AttributeMessageBuilder include(Set<Attribute> includeSet)
      Specifies a set of attributes that should be included in serialization.
      Parameters:
      includeSet - the set of attributes to include.
      Returns:
      the builder for chaining purposes.
    • exclude

      public AttributeMessageBuilder exclude(Set<Attribute> excludeSet)
      Specifies a set of attributes that should be excluded from serialization.
      Parameters:
      excludeSet - the set of attributes to exclude.
      Returns:
      the builder for chaining purposes.
    • highlight

      public AttributeMessageBuilder highlight(Set<Attribute> highlightSet)
      Specifies a set of attributes that should be highlighted as a property of the MqMessage.
      Parameters:
      highlightSet - the set of attributes to highlight.
      Returns:
      the builder for chaining purposes.
    • build

      public MqMessage build()
      Builds an MqMessage based on the information collected.
    • highlightedPropertyName

      public static String highlightedPropertyName(boolean isBefore, Attribute attribute)
      Returns the property name used for a highlighted attribute.
      Parameters:
      isBefore - true, if attribute value was within the before half of a subject pair.
      attribute - the highlighted attribute.