1 package org.apache.commons.jcs3.engine.control.event;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.util.EventObject;
23
24 import org.apache.commons.jcs3.engine.control.event.behavior.ElementEventType;
25 import org.apache.commons.jcs3.engine.control.event.behavior.IElementEvent;
26
27 /**
28 * Element events will trigger the creation of Element Event objects. This is a wrapper around the
29 * cache element that indicates the event triggered.
30 */
31 public class ElementEvent<T>
32 extends EventObject
33 implements IElementEvent<T>
34 {
35 /** Don't change */
36 private static final long serialVersionUID = -5364117411457467056L;
37
38 /** default event code */
39 private ElementEventType elementEvent = ElementEventType.EXCEEDED_MAXLIFE_BACKGROUND;
40
41 /**
42 * Constructor for the ElementEvent object
43 * <p>
44 * @param source The Cache Element
45 * @param elementEvent The event id defined in the enum class.
46 */
47 public ElementEvent( final T source, final ElementEventType elementEvent )
48 {
49 super( source );
50 this.elementEvent = elementEvent;
51 }
52
53 /**
54 * Gets the elementEvent attribute of the ElementEvent object
55 * <p>
56 * @return The elementEvent value. The List of values is defined in ElementEventType.
57 */
58 @Override
59 public ElementEventType getElementEvent()
60 {
61 return elementEvent;
62 }
63
64 /**
65 * @return the source of the event.
66 */
67 @SuppressWarnings("unchecked") // Generified
68 @Override
69 public T getSource()
70 {
71 return (T) super.getSource();
72
73 }
74 }