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 /** 34 * The event source. 35 */ 36 protected transient Object source; 37 38 /** 39 * Constructs a new instance of this class. 40 * 41 * @param source 42 * the object which fired the event. 43 */ 44 public EventObject(Object source) { 45 if (source != null) { 46 this.source = source; 47 } else { 48 throw new IllegalArgumentException(); 49 } 50 } 51 52 /** 53 * Returns the event source. 54 * 55 * @return the object which fired the event. 56 */ 57 public Object getSource() { 58 return source; 59 } 60 61 /** 62 * Returns the string representation of this {@code EventObject}. 63 * 64 * @return the string representation of this {@code EventObject}. 65 */ 66 @Override 67 public String toString() { 68 return getClass().getName() + "[source=" + source + ']'; //$NON-NLS-1$ 69 } 70} 71