View Javadoc
1   /*
2    * Copyright © 2016 Greg Chabala
3    *
4    * This file is part of brick-control-lab.
5    *
6    * brick-control-lab is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Lesser General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   *
11   * brick-control-lab is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Lesser General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public License
17   * along with brick-control-lab.  If not, see http://www.gnu.org/licenses/.
18   */
19  package org.chabala.brick.controllab;
20  
21  import java.util.EventObject;
22  
23  /**
24   * The event triggered by interacting with the red stop button on the control
25   * lab.
26   */
27  public class StopButtonEvent extends EventObject {
28  
29      private final byte rawValue;
30  
31      /**
32       * Constructs a StopButtonEvent.
33       *
34       * @param source The object on which the Event initially occurred.
35       * @param rawValue The raw data that signaled this event.
36       * @throws IllegalArgumentException if source is null.
37       */
38      public StopButtonEvent(Object source, byte rawValue) {
39          super(source);
40          this.rawValue = rawValue;
41      }
42  
43      /**
44       * The raw data that signaled this event.
45       * @return The raw data that signaled this event.
46       */
47      public byte getRawValue() {
48          return rawValue;
49      }
50  
51      /** {@inheritDoc} */
52      @Override
53      public String toString() {
54          return "StopButtonEvent{" +
55                  "source=" + source +
56                  ", rawValue=" + String.format("0x%02X ", rawValue) +
57                  '}';
58      }
59  }