Class MessageBuilderInvocationHandler

  • All Implemented Interfaces:
    java.lang.reflect.InvocationHandler

    public class MessageBuilderInvocationHandler
    extends java.lang.Object
    implements java.lang.reflect.InvocationHandler
    Invocation handler that builds message based on called performed.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String buildMessage()
      Build the message based on annotations from methods called previously.
      java.lang.Object invoke​(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MessageBuilderInvocationHandler

        public MessageBuilderInvocationHandler​(java.lang.String context)
        Creates a new message builder invocation handler.
        Parameters:
        context - base context of the generated message
      • MessageBuilderInvocationHandler

        public MessageBuilderInvocationHandler​(java.lang.String context,
                                               java.lang.Object instance)
        Creates a new message builder invocation handler.
        Parameters:
        context - base context of the generated message
        instance - underlying wrapped instance. If not null, calls will also be performed on this instance.
      • MessageBuilderInvocationHandler

        public MessageBuilderInvocationHandler​(java.util.List<MessageBuilderCall> calls)
        Creates a new message builder invocation handler, with initial calls.
        Parameters:
        calls - initial calls.
    • Method Detail

      • invoke

        public java.lang.Object invoke​(java.lang.Object proxy,
                                       java.lang.reflect.Method method,
                                       java.lang.Object[] args)
                                throws java.lang.Throwable
        Specified by:
        invoke in interface java.lang.reflect.InvocationHandler
        Throws:
        java.lang.Throwable
      • buildMessage

        public java.lang.String buildMessage()
        Build the message based on annotations from methods called previously.
        Returns:
        built message
        Throws:
        java.lang.IllegalStateException - if one of the recorded call has no @Message/@NotMessage annotation.