1 package org.djutils.event; 2 3 import org.djutils.metadata.MetaData; 4 5 /** 6 * The EventType is the description of a topic used for the subscription to asynchronous events. Event types are used by 7 * EventProducers to show which events they potentially fire. EventTypes are typically defined as static final fields. This 8 * class only accepts when the producer fires events of type Event, and not a subclass of Event. <br> 9 * <br> 10 * Copyright (c) 2020-2022 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See 11 * for project information <a href="https://djutils.org" target="_blank"> https://djutils.org</a>. The DJUTILS project is 12 * distributed under a three-clause BSD-style license, which can be found at 13 * <a href="https://djutils.org/docs/license.html" target="_blank"> https://djutils.org/docs/license.html</a>. <br> 14 * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a> 15 * @author <a href="https://www.tudelft.nl/pknoppers">Peter Knoppers</a> 16 */ 17 public class EventType extends AbstractEventType 18 { 19 /** */ 20 private static final long serialVersionUID = 20200505L; 21 22 /** 23 * Construct a new EventType. Only events of the type Event, and no subclasses of Event, can be used to fire events of this 24 * type. This means that firing a TimedEvent of this type will result in an error. 25 * @param name String; the name of the new eventType. Two values are not appreciated: null and the empty string. 26 * @param metaData MetaData; describes the payload of events of the new EventType; 27 */ 28 public EventType(final String name, final MetaData metaData) 29 { 30 super(name, metaData, Event.class); 31 } 32 33 /** 34 * Construct a new EventType. The name of the metadata will function as the name of the event. Only events of the type 35 * Event, and no subclasses of Event, can be used to fire events of this type. This means that firing a TimedEvent of this 36 * type will result in an error. 37 * @param metaData MetaData; describes the payload of events of the new EventType; 38 */ 39 public EventType(final MetaData metaData) 40 { 41 super(metaData == null ? null : metaData.getName(), metaData, Event.class); 42 } 43 44 /** 45 * Construct a new EventType with no meta data. Only events of the type Event, and no subclasses of Event, can be used to 46 * fire events of this type. This means that firing a TimedEvent of this type will result in an error. 47 * @param name String; the name of the new eventType. Two values are not appreciated: null and the empty string. 48 */ 49 @Deprecated 50 public EventType(final String name) 51 { 52 super(name, MetaData.NO_META_DATA, Event.class); 53 } 54 55 }