//# 0 errors, 103 messages
//#
/*
    //#message.java:1:1: class: net.sourceforge.pebble.domain.Message
    //#message.java:1:1: method: net.sourceforge.pebble.domain.Message.net.sourceforge.pebble.domain.Message__static_init
 * Copyright (c) 2003-2006, Simon Brown
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 *   - Neither the name of Pebble nor the names of its contributors may
 *     be used to endorse or promote products derived from this software
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package net.sourceforge.pebble.domain;

import net.sourceforge.pebble.util.SecurityUtils;

import java.util.Date;

/**
 * Represents a message, created by Pebble for the user.
 *
 * @author    Simon Brown
 */
public class Message {

  private MessageType type;
  private Date date;
  private String text;

  public Message(MessageType type, String text) {
    //#message.java:49: method: void net.sourceforge.pebble.domain.Message.net.sourceforge.pebble.domain.Message(MessageType, String)
    //#input(void net.sourceforge.pebble.domain.Message(MessageType, String)): text
    //#input(void net.sourceforge.pebble.domain.Message(MessageType, String)): this
    //#input(void net.sourceforge.pebble.domain.Message(MessageType, String)): type
    //#output(void net.sourceforge.pebble.domain.Message(MessageType, String)): new Date(Message#1) num objects
    //#output(void net.sourceforge.pebble.domain.Message(MessageType, String)): this.date
    //#output(void net.sourceforge.pebble.domain.Message(MessageType, String)): this.text
    //#output(void net.sourceforge.pebble.domain.Message(MessageType, String)): this.type
    //#new obj(void net.sourceforge.pebble.domain.Message(MessageType, String)): new Date(Message#1)
    //#post(void net.sourceforge.pebble.domain.Message(MessageType, String)): this.date == &new Date(Message#1)
    //#post(void net.sourceforge.pebble.domain.Message(MessageType, String)): init'ed(this.text)
    //#post(void net.sourceforge.pebble.domain.Message(MessageType, String)): this.type == type
    //#post(void net.sourceforge.pebble.domain.Message(MessageType, String)): init'ed(this.type)
    //#post(void net.sourceforge.pebble.domain.Message(MessageType, String)): new Date(Message#1) num objects == 1
    //#unanalyzed(void net.sourceforge.pebble.domain.Message(MessageType, String)): Effects-of-calling:net.sourceforge.pebble.util.SecurityUtils:getUsername
    //#unanalyzed(void net.sourceforge.pebble.domain.Message(MessageType, String)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void net.sourceforge.pebble.domain.Message(MessageType, String)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void net.sourceforge.pebble.domain.Message(MessageType, String)): Effects-of-calling:java.lang.StringBuilder:toString
    this.type = type;
    setText(text);
    this.date = new Date();
  }
    //#message.java:53: end of method: void net.sourceforge.pebble.domain.Message.net.sourceforge.pebble.domain.Message(MessageType, String)

  public Date getDate() {
    return date;
    //#message.java:56: method: Date net.sourceforge.pebble.domain.Message.getDate()
    //#input(Date getDate()): this
    //#input(Date getDate()): this.date
    //#output(Date getDate()): return_value
    //#pre[2] (Date getDate()): init'ed(this.date)
    //#post(Date getDate()): return_value == this.date
    //#post(Date getDate()): init'ed(return_value)
    //#message.java:56: end of method: Date net.sourceforge.pebble.domain.Message.getDate()
  }

  public String getText() {
    return text;
    //#message.java:60: method: String net.sourceforge.pebble.domain.Message.getText()
    //#input(String getText()): this
    //#input(String getText()): this.text
    //#output(String getText()): return_value
    //#pre[2] (String getText()): init'ed(this.text)
    //#post(String getText()): return_value == this.text
    //#post(String getText()): init'ed(return_value)
    //#message.java:60: end of method: String net.sourceforge.pebble.domain.Message.getText()
  }

  private void setText(String text) {
    String username = SecurityUtils.getUsername();
    //#message.java:64: method: void net.sourceforge.pebble.domain.Message.setText(String)
    //#message.java:64: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.util.SecurityUtils:getUsername()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.domain.Message
    //#    method: void setText(String)
    //#    unanalyzed callee: String net.sourceforge.pebble.util.SecurityUtils:getUsername()
    //#input(void setText(String)): text
    //#input(void setText(String)): this
    //#output(void setText(String)): this.text
    //#post(void setText(String)): init'ed(this.text)
    //#test_vector(void setText(String)): net.sourceforge.pebble.util.SecurityUtils:getUsername(...)@64: Addr_Set{null}, Inverse{null}
    if (username != null) {
      this.text = "[" + username + "] " + text;
    } else {
      this.text = text;
    }
  }
    //#message.java:70: end of method: void net.sourceforge.pebble.domain.Message.setText(String)

  public MessageType getType() {
    return type;
    //#message.java:73: method: MessageType net.sourceforge.pebble.domain.Message.getType()
    //#input(MessageType getType()): this
    //#input(MessageType getType()): this.type
    //#output(MessageType getType()): return_value
    //#pre[2] (MessageType getType()): init'ed(this.type)
    //#post(MessageType getType()): return_value == this.type
    //#post(MessageType getType()): init'ed(return_value)
    //#message.java:73: end of method: MessageType net.sourceforge.pebble.domain.Message.getType()
  }

  public boolean equals(Object o) {
    if (this == o) return true;
    //#message.java:77: method: bool net.sourceforge.pebble.domain.Message.equals(Object)
    //#input(bool equals(Object)): __Descendant_Table[net/sourceforge/pebble/domain/Message]
    //#input(bool equals(Object)): __Descendant_Table[others]
    //#input(bool equals(Object)): o
    //#input(bool equals(Object)): o.__Tag
    //#input(bool equals(Object)): o.date
    //#input(bool equals(Object)): o.text
    //#input(bool equals(Object)): this
    //#input(bool equals(Object)): this.date
    //#input(bool equals(Object)): this.text
    //#output(bool equals(Object)): return_value
    //#pre[4] (bool equals(Object)): (soft) o.__Tag == net/sourceforge/pebble/domain/Message
    //#pre[5] (bool equals(Object)): (soft) init'ed(o.date)
    //#pre[6] (bool equals(Object)): (soft) init'ed(o.text)
    //#pre[9] (bool equals(Object)): (soft) this.date != null
    //#pre[10] (bool equals(Object)): (soft) init'ed(this.text)
    //#post(bool equals(Object)): init'ed(return_value)
    //#test_vector(bool equals(Object)): o: Inverse{null}, Addr_Set{null}
    //#test_vector(bool equals(Object)): o.text: Addr_Set{null}, Inverse{null}
    //#test_vector(bool equals(Object)): this == o: {0}, {1}
    //#test_vector(bool equals(Object)): this.text: Inverse{null}, Addr_Set{null}
    //#test_vector(bool equals(Object)): java.util.Date:equals(...)@82: {1}, {0}
    if (o == null || getClass() != o.getClass()) return false;

    final Message message = (Message) o;

    if (!date.equals(message.date)) return false;
    if (text != null ? !text.equals(message.text) : message.text != null) return false;

    return true;
    //#message.java:85: end of method: bool net.sourceforge.pebble.domain.Message.equals(Object)
  }

  public int hashCode() {
    int result;
    result = date.hashCode();
    //#message.java:90: method: int net.sourceforge.pebble.domain.Message.hashCode()
    //#input(int hashCode()): this
    //#input(int hashCode()): this.date
    //#input(int hashCode()): this.text
    //#output(int hashCode()): return_value
    //#pre[2] (int hashCode()): this.date != null
    //#pre[3] (int hashCode()): init'ed(this.text)
    //#presumption(int hashCode()): java.util.Date:hashCode(...)@90 in -222_153_480..222_153_480
    //#presumption(int hashCode()): java.util.Date:hashCode(...)@90*29 + java.lang.String:hashCode(...) in -2_147_483_648..4_294_967_295
    //#post(int hashCode()): (soft) init'ed(return_value)
    result = 29 * result + (text != null ? text.hashCode() : 0);
    return result;
    //#message.java:92: end of method: int net.sourceforge.pebble.domain.Message.hashCode()
  }

}    //#output(net.sourceforge.pebble.domain.Message__static_init): __Descendant_Table[net/sourceforge/pebble/domain/Message]
    //#output(net.sourceforge.pebble.domain.Message__static_init): __Dispatch_Table.equals(Ljava/lang/Object;)Z
    //#output(net.sourceforge.pebble.domain.Message__static_init): __Dispatch_Table.getDate()Ljava/util/Date;
    //#output(net.sourceforge.pebble.domain.Message__static_init): __Dispatch_Table.getText()Ljava/lang/String;
    //#output(net.sourceforge.pebble.domain.Message__static_init): __Dispatch_Table.getType()Lnet/sourceforge/pebble/domain/MessageType;
    //#output(net.sourceforge.pebble.domain.Message__static_init): __Dispatch_Table.hashCode()I
    //#output(net.sourceforge.pebble.domain.Message__static_init): __Dispatch_Table.setText(Ljava/lang/String;)V
    //#post(net.sourceforge.pebble.domain.Message__static_init): __Descendant_Table[net/sourceforge/pebble/domain/Message] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.domain.Message__static_init): __Dispatch_Table.equals(Ljava/lang/Object;)Z == &equals
    //#post(net.sourceforge.pebble.domain.Message__static_init): __Dispatch_Table.getDate()Ljava/util/Date; == &getDate
    //#post(net.sourceforge.pebble.domain.Message__static_init): __Dispatch_Table.getText()Ljava/lang/String; == &getText
    //#post(net.sourceforge.pebble.domain.Message__static_init): __Dispatch_Table.getType()Lnet/sourceforge/pebble/domain/MessageType; == &getType
    //#post(net.sourceforge.pebble.domain.Message__static_init): __Dispatch_Table.hashCode()I == &hashCode
    //#post(net.sourceforge.pebble.domain.Message__static_init): __Dispatch_Table.setText(Ljava/lang/String;)V == &setText
    //#message.java:: end of method: net.sourceforge.pebble.domain.Message.net.sourceforge.pebble.domain.Message__static_init
    //#message.java:: end of class: net.sourceforge.pebble.domain.Message
