1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18package java.util; 19 20 21import java.io.Serializable; 22 23/** 24 * {@code EventObject}s represent events. Typically applications subclass this class to 25 * add event specific information. 26 * 27 * @see EventListener 28 */ 29public class EventObject implements Serializable { 30 31 private static final long serialVersionUID = 5516075349620653480L; 32 33 @FindBugsSuppressWarnings("SE_TRANSIENT_FIELD_NOT_RESTORED") 34 protected transient Object source; 35 36 /** 37 * Constructs a new instance of this class. 38 * 39 * @param source 40 * the object which fired the event. 41 */ 42 public EventObject(Object source) { 43 if (source == null) { 44 throw new IllegalArgumentException("source == null"); 45 } 46 this.source = source; 47 } 48 49 /** 50 * Returns the object which fired the event. 51 */ 52 public Object getSource() { 53 return source; 54 } 55 56 /** 57 * Returns the string representation of this {@code EventObject}. 58 */ 59 @Override public String toString() { 60 return getClass().getName() + "[source=" + source + ']'; 61 } 62} 63