package de.ugoe.cs.eventbench.data; import java.util.LinkedList; import java.util.List; import de.ugoe.cs.eventbench.IReplayDecorator; /** *
* Subclass of {@link Event} for events that contain all informations required * for replaying them, i.e., generating scripts that can used for automated * software execution. *
* * @author Steffen Herbold * @version 1.0 * * @param
* List of {@link IReplayable}s of type T that describes the replay of an
* event. The {@link IReplayable}s can be interpreted as
* Defines whether the replay is valid or invalid. It may be invalid, e.g., * due to errors during the generation of the event or lack of vital * information. *
*/ protected boolean replayValid = true; /** ** {@link IReplayDecorator} used when replays of this type are written. *
*/ protected IReplayDecorator decorator = null; /** ** Constructor. Creates a new event with the given type. *
* * @param type * type of the event * @see Event#Event(String) */ public ReplayableEvent(String type) { super(type); } /** *
* Adds a new {@link IReplayable} of type T to the replay sequence. *
* * @param replayable * element that is added to the sequence */ public void addReplayEvent(T replayable) { replayEvents.add(replayable); } /** ** Adds a {@link List}ist of {@link IReplayable} to the replay sequence. *
* * @param generatedReplaySeq * {@link List} that is added to the sequence */ public void addReplaySequence(List* Returns the {@link IReplayDecorator} of the event. *
* * @return {@link IReplayDecorator} of the event; null if no decorator has * been set */ public IReplayDecorator getReplayDecorator() { return decorator; } /** ** Returns a the list of replay events. *
** The return value is a copy of the list used internally! *
* * @return list of replay events. */ public List* Returns whether the replay is valid or not. *
* * @return true, if replay is valid; false otherwise. */ public boolean hasValidReplay() { return replayValid; } /** ** Marks the replay as invalid. Once marked as invalid, it remains so and * cannot be changed back to valid. *
*/ public void invalidateReplay() { replayValid = false; } /** ** Sets the {@link IReplayDecorator} associated with the event. *
* * @param decorator * decorator associated with the event */ public void setDecorator(IReplayDecorator decorator) { this.decorator = decorator; } /* (non-Javadoc) * @see de.ugoe.cs.eventbench.data.Event#equals(java.lang.Object) */ @Override public boolean equals(Object other) { if (this == other) { return true; } if (other instanceof ReplayableEvent>) { ReplayableEvent> otherEvent = (ReplayableEvent>) other; return super.equals(otherEvent) && replayEvents.equals(otherEvent.replayEvents) && replayValid == otherEvent.replayValid; } else { return false; } } /* (non-Javadoc) * @see de.ugoe.cs.eventbench.data.Event#hashCode() */ @Override public int hashCode() { int multiplier = 17; int hash = super.hashCode(); hash = multiplier * hash + replayEvents.hashCode(); hash = multiplier * hash + (replayValid ? 1 : 0); return hash; } }