TrafficLightColor.java

  1. package org.opentrafficsim.road.network.lane.object.trafficlight;

  2. /**
  3.  * The colors for a normal traffic light.
  4.  * <p>
  5.  * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  6.  * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
  7.  * </p>
  8.  * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
  9.  * initial version Oct 6, 2016 <br>
  10.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  11.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  12.  * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
  13.  */
  14. public enum TrafficLightColor
  15. {
  16.     /** GTU needs to stop. */
  17.     RED,

  18.     /** GTU is allowed to continue if it cannot stop anymore. */
  19.     YELLOW,

  20.     /** GTU is allowed to drive. */
  21.     GREEN,

  22.     /** Pre-green indication. */
  23.     PREGREEN,

  24.     /** Traffic light is not working. */
  25.     BLACK;

  26.     /** @return whether the light is red or yellow. */
  27.     public final boolean isRedOrYellow()
  28.     {
  29.         return this.equals(RED) | this.equals(YELLOW);
  30.     }

  31.     /** @return whether the light is red. */
  32.     public final boolean isRed()
  33.     {
  34.         return this.equals(RED);
  35.     }

  36.     /** @return whether the light is yellow. */
  37.     public final boolean isYellow()
  38.     {
  39.         return this.equals(YELLOW);
  40.     }

  41.     /** @return whether the light is green. */
  42.     public final boolean isGreen()
  43.     {
  44.         return this.equals(GREEN);
  45.     }

  46.     /** @return whether the light is pre-green. */
  47.     public final boolean isPreGreen()
  48.     {
  49.         return this.equals(PREGREEN);
  50.     }

  51.     /** @return whether the light is black (off). */
  52.     public final boolean isBlack()
  53.     {
  54.         return this.equals(BLACK);
  55.     }

  56. }