/*
 * The MIT License
 *
 * Copyright (c) 2017 Marcelo "Ataxexe" Guimarães <ataxexe@devnull.tools>
 *
 * Permission  is hereby granted, free of charge, to any person obtaining
 * a  copy  of  this  software  and  associated  documentation files (the
 * "Software"),  to  deal  in the Software without restriction, including
 * without  limitation  the  rights to use, copy, modify, merge, publish,
 * distribute,  sublicense,  and/or  sell  copies of the Software, and to
 * permit  persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * The  above  copyright  notice  and  this  permission  notice  shall be
 * included  in  all  copies  or  substantial  portions  of the Software.
 *
 * THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY OF ANY KIND,
 * EXPRESS  OR  IMPLIED,  INCLUDING  BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN  NO  EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM,  DAMAGES  OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT  OR  OTHERWISE,  ARISING  FROM,  OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE   OR   THE   USE   OR   OTHER   DEALINGS  IN  THE  SOFTWARE.
 */

package tools.devnull.boteco.message;

import java.io.Serializable;

/**
 * Interface that defines something that can be sent through boteco
 * as a message.
 */
public interface Sendable extends Serializable {

  /**
   * Returns the message that describes this object.
   *
   * @return the message that should be sent to the subscribers.
   * @see tools.devnull.boteco.ContentFormatter
   * @see tools.devnull.boteco.message.FormatExpressionParser
   */
  String message();

  /**
   * Returns the title of the message (if applicable).
   *
   * @return the title of the message
   */
  String title();

  /**
   * Returns a url that points to the subject of the message (if applicable).
   *
   * @return a url that points to the subject of the message.
   */
  String url();

  /**
   * Returns the priority of this message.
   *
   * @return the priority of this message.
   */
  default Priority priority() {
    return Priority.NORMAL;
  }

  /**
   * Creates a new sendable object by appending the given content to its message.
   *
   * @param content the content to append
   * @return a new sendable object
   */
  default Sendable append(String content) {
    return new Sendable() {
      @Override
      public String message() {
        return this.message() + content;
      }

      @Override
      public String title() {
        return this.title();
      }

      @Override
      public String url() {
        return this.url();
      }
    };
  }

  /**
   * Creates a new sendable object by prepending the given content to its message.
   *
   * @param content the content to prepend
   * @return a new sendable object
   */
  default Sendable prepend(String content) {
    return new Sendable() {
      @Override
      public String message() {
        return content + this.message();
      }

      @Override
      public String title() {
        return this.title();
      }

      @Override
      public String url() {
        return this.url();
      }
    };
  }

  /**
   * Creates a new sendable object using the given content as the message.
   *
   * @param content the content of the message
   * @return a new sendable object
   */
  static Sendable message(String content) {
    return new Sendable() {
      private static final long serialVersionUID = -2676259626347572106L;

      @Override
      public String message() {
        return content;
      }

      @Override
      public String title() {
        return null;
      }

      @Override
      public String url() {
        return null;
      }
    };
  }

}

@@ -2430,32 +2430,107 @@
 ew Sendable() %7B%0A
+      private static final long serialVersionUID = -2676259626347572106L;%0A%0A
       @Override%0A
@@ -2572,24 +2572,33 @@
      return 
+Sendable.
 this.message
@@ -2673,32 +2673,41 @@
 %0A        return 
+Sendable.
 this.title();%0A  
@@ -2764,32 +2764,41 @@
 %0A        return 
+Sendable.
 this.url();%0A    
@@ -3060,24 +3060,99 @@
 endable() %7B%0A
+      private static final long serialVersionUID = -7677315645960771732L;%0A%0A
       @Overr
@@ -3212,16 +3212,25 @@
 ntent + 
+Sendable.
 this.mes
@@ -3303,24 +3303,33 @@
      return 
+Sendable.
 this.title()
@@ -3398,16 +3398,25 @@
  return 
+Sendable.
 this.url

make tests pass