com.alachisoft.ncache.client.internal.caching.CustomEvent Maven / Gradle / Ivy
/*
* @(#)CustomEventListener.java
*
* Created on September 14, 2006, 11:53 AM
*
* Copyright 2005 Alachisoft, Inc. All rights reserved.
* ALACHISOFT PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.alachisoft.ncache.client.internal.caching;
//~--- non-JDK imports --------------------------------------------------------
import java.util.EventObject;
//~--- JDK imports ------------------------------------------------------------
//~--- classes ----------------------------------------------------------------
/**
* CustomEvent is used to notify interested parties that
* something has happened with respect to a custom event.
*
* @author Arif Iftikhar
* @version 0.1
*/
class CustomEvent extends EventObject {
//~--- fields -------------------------------------------------------------
//~--- constructors -------------------------------------------------------
private EventType type;
//~--- methods ------------------------------------------------------------
//~--- get methods --------------------------------------------------------
private Object key;
private Object value;
/**
* Creates a new object representing a custom event.
*
* @param source the cache object responsible for the event
* @param type the event type
* @param key the key of the item.
* @param value the value of the item.
*/
public CustomEvent(Object source, EventType type, Object key, Object value) {
super(source);
this.type = type;
this.key = key;
this.value = value;
}
/**
* Gets the type of event.
*
* @return the type
*/
public EventType getEventType() {
return type;
}
/**
* Returns the Key of the item for which this event occured.
*
* @return Returns the Key of the item for which this event occured.
*/
public Object getKey() {
return key;
}
/**
* Returns the Value of the item for which this event occured.
*
* @return Returns the Key of the item for which this event occured.
*/
public Object getValue() {
return value;
}
/**
* Defines the CUSTOM event type, along
* with its string representation, returned by toString().
*/
public static final class EventType {
/**
* Custom type.
*/
public static final EventType CUSTOM = new EventType("CUSTOM");
private String typeString;
/**
* @param s
*/
private EventType(String s) {
typeString = s;
}
/**
* Converts the type to a string.
*
* @return the string
*/
public String toString() {
return typeString;
}
}
}