View Javadoc

1   package com.github.triceo.splitlog.api;
2   
3   /**
4    * Used by {@link MessageMetric} to determine how much a {@link Message} is
5    * worth. Users are discouraged from implementing these as stateful - doing so
6    * will result in unpredictable behavior, as a single instance of the class can
7    * be shared across multiple {@link MessageMetric}s.
8    *
9    * @param <T>
10   *            The value type returned by the metric.
11   * @param <S>
12   *            Where this is getting its {@link Message}s from.
13   */
14  public interface MessageMeasure<T extends Number, S extends MessageProducer<S>> {
15  
16      /**
17       * The default value for the resulting {@link MessageMetric}.
18       * 
19       * @return Whetever value that the metric should start with.
20       */
21      T initialValue();
22  
23      /**
24       * Update metric after the arrival of another message.
25       *
26       * @param metric
27       *            The metric that is being updated.
28       * @param evaluate
29       *            The message to evaluate.
30       * @param status
31       *            Current processing status of the message.
32       * @param source
33       *            The notifying object.
34       * @return The new value for the metric. Message count will be incremented
35       *         automatically.
36       */
37      T update(MessageMetric<T, S> metric, Message evaluate, MessageDeliveryStatus status, S source);
38  
39  }