//# 0 errors, 60 messages
//#
/*
    //#PreviousCommand.java:1:1: class: com.dmdirc.commandparser.commands.PreviousCommand
    //#PreviousCommand.java:1:1: method: com.dmdirc.commandparser.commands.PreviousCommand.com.dmdirc.commandparser.commands.PreviousCommand__static_init
 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
 *
 * 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 com.dmdirc.commandparser.commands;

import java.util.Date;

/**
 * Stores information about a previously executed command.
 * 
 * @author chris
 */
public final class PreviousCommand {
   
    /** The full command that was executed. */
    private final String line;
    
    /** The timestamp of its execution. */
    private final long time;
    
    /**
     * Creates a new record of the specified command.
     * 
     * @param line The full command that was executed
     */
    public PreviousCommand(final String line) {
    //#PreviousCommand.java:45: method: void com.dmdirc.commandparser.commands.PreviousCommand.com.dmdirc.commandparser.commands.PreviousCommand(String)
    //#input(void com.dmdirc.commandparser.commands.PreviousCommand(String)): line
    //#input(void com.dmdirc.commandparser.commands.PreviousCommand(String)): this
    //#output(void com.dmdirc.commandparser.commands.PreviousCommand(String)): this.line
    //#output(void com.dmdirc.commandparser.commands.PreviousCommand(String)): this.time
    //#post(void com.dmdirc.commandparser.commands.PreviousCommand(String)): this.line == line
    //#post(void com.dmdirc.commandparser.commands.PreviousCommand(String)): init'ed(this.line)
    //#post(void com.dmdirc.commandparser.commands.PreviousCommand(String)): init'ed(this.time)
        this.line = line;
        this.time = new Date().getTime();
    }
    //#PreviousCommand.java:48: end of method: void com.dmdirc.commandparser.commands.PreviousCommand.com.dmdirc.commandparser.commands.PreviousCommand(String)
    
    /**
     * Retrieves the time that the command was executed at.
     * 
     * @return The timestamp that the command was executed at
     */
    public long getTime() {
        return time;
    //#PreviousCommand.java:56: method: long com.dmdirc.commandparser.commands.PreviousCommand.getTime()
    //#input(long getTime()): this
    //#input(long getTime()): this.time
    //#output(long getTime()): return_value
    //#post(long getTime()): return_value == this.time
    //#post(long getTime()): init'ed(return_value)
    //#PreviousCommand.java:56: end of method: long com.dmdirc.commandparser.commands.PreviousCommand.getTime()
    }
    
    /**
     * Retrieves the command that was executed.
     * 
     * @return The command that was executed.
     */
    public String getLine() {
        return line;
    //#PreviousCommand.java:65: method: String com.dmdirc.commandparser.commands.PreviousCommand.getLine()
    //#input(String getLine()): this
    //#input(String getLine()): this.line
    //#output(String getLine()): return_value
    //#post(String getLine()): return_value == this.line
    //#post(String getLine()): init'ed(return_value)
    //#PreviousCommand.java:65: end of method: String com.dmdirc.commandparser.commands.PreviousCommand.getLine()
    }

    /** {@inheritDoc} */
    @Override
    public boolean equals(final Object obj) {
        if (obj == null) {
    //#PreviousCommand.java:71: method: bool com.dmdirc.commandparser.commands.PreviousCommand.equals(Object)
    //#input(bool equals(Object)): __Descendant_Table[com/dmdirc/commandparser/commands/PreviousCommand]
    //#input(bool equals(Object)): __Descendant_Table[others]
    //#input(bool equals(Object)): obj
    //#input(bool equals(Object)): obj.__Tag
    //#input(bool equals(Object)): obj.line
    //#input(bool equals(Object)): this
    //#input(bool equals(Object)): this.line
    //#output(bool equals(Object)): return_value
    //#pre[2] (bool equals(Object)): (soft) obj.__Tag == com/dmdirc/commandparser/commands/PreviousCommand
    //#post(bool equals(Object)): init'ed(return_value)
    //#test_vector(bool equals(Object)): obj: Inverse{null}, Addr_Set{null}
    //#test_vector(bool equals(Object)): this.line: Addr_Set{null}, Inverse{null}
    //#test_vector(bool equals(Object)): this.line == obj.line: {1}, {0}
    //#test_vector(bool equals(Object)): java.lang.String:equals(...)@80: {1}, {0}
            return false;
        }
        
        if (getClass() != obj.getClass()) {
            return false;
        }
        
        final PreviousCommand other = (PreviousCommand) obj;
        if (this.line != other.line
                && (this.line == null || !this.line.equals(other.line))) {
            return false;
        }
        
        return true;
    //#PreviousCommand.java:85: end of method: bool com.dmdirc.commandparser.commands.PreviousCommand.equals(Object)
    }

    /** {@inheritDoc} */
    @Override
    public int hashCode() {
        int hash = 5;
    //#PreviousCommand.java:91: method: int com.dmdirc.commandparser.commands.PreviousCommand.hashCode()
    //#input(int hashCode()): this
    //#input(int hashCode()): this.line
    //#output(int hashCode()): return_value
    //#presumption(int hashCode()): java.lang.String:hashCode(...)@92 <= 4_294_966_810
    //#post(int hashCode()): return_value >= -2_147_483_163
        hash = 97 * hash + (this.line == null ? 0 : this.line.hashCode());
        return hash;
    //#PreviousCommand.java:93: end of method: int com.dmdirc.commandparser.commands.PreviousCommand.hashCode()
    }
    
}    //#output(com.dmdirc.commandparser.commands.PreviousCommand__static_init): __Descendant_Table[com/dmdirc/commandparser/commands/PreviousCommand]
    //#output(com.dmdirc.commandparser.commands.PreviousCommand__static_init): __Dispatch_Table.equals(Ljava/lang/Object;)Z
    //#output(com.dmdirc.commandparser.commands.PreviousCommand__static_init): __Dispatch_Table.getLine()Ljava/lang/String;
    //#output(com.dmdirc.commandparser.commands.PreviousCommand__static_init): __Dispatch_Table.getTime()J
    //#output(com.dmdirc.commandparser.commands.PreviousCommand__static_init): __Dispatch_Table.hashCode()I
    //#post(com.dmdirc.commandparser.commands.PreviousCommand__static_init): __Descendant_Table[com/dmdirc/commandparser/commands/PreviousCommand] == &__Dispatch_Table
    //#post(com.dmdirc.commandparser.commands.PreviousCommand__static_init): __Dispatch_Table.equals(Ljava/lang/Object;)Z == &equals
    //#post(com.dmdirc.commandparser.commands.PreviousCommand__static_init): __Dispatch_Table.getLine()Ljava/lang/String; == &getLine
    //#post(com.dmdirc.commandparser.commands.PreviousCommand__static_init): __Dispatch_Table.getTime()J == &getTime
    //#post(com.dmdirc.commandparser.commands.PreviousCommand__static_init): __Dispatch_Table.hashCode()I == &hashCode
    //#PreviousCommand.java:: end of method: com.dmdirc.commandparser.commands.PreviousCommand.com.dmdirc.commandparser.commands.PreviousCommand__static_init
    //#PreviousCommand.java:: end of class: com.dmdirc.commandparser.commands.PreviousCommand
