Package monq.jfa

Interface StateValueMerger<V>

Type Parameters:
V - type of values to merge
All Known Implementing Classes:
PrioritizedValueMerger
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface StateValueMerger<V>
Merges a list of values into one result.
  • Method Summary

    Modifier and Type
    Method
    Description
    merge(List<V> values)
    Should derive a value V from the values provided.
    static <T> StateValueMerger<T>
    Provides a merger which fails if the given list of values contains more than one different value, where "different" is decided by identity (==) rather than equals().
  • Method Details

    • strict

      static <T> StateValueMerger<T> strict()
      Provides a merger which fails if the given list of values contains more than one different value, where "different" is decided by identity (==) rather than equals().
    • merge

      V merge(List<V> values) throws CompileDfaException
      Should derive a value V from the values provided. The result may be one of the values provided or a newly created one. Changing one of the provided values is most likely not what you should do.

      The result of the method should not depend on the order of the values. The parameter is not a Set mainly because this would require that values behave sanely as set members (hashCode, equals).

      Parameters:
      values - is guaranteed to contain at least two values
      Returns:
      should never be null
      Throws:
      CompileDfaException - if no useful value can be determined
      IllegalArgumentException - if the list is empty