org.apache.cayenne.event
Class EventSubject
java.lang.Object
org.apache.cayenne.event.EventSubject
- All Implemented Interfaces:
- java.io.Serializable
public class EventSubject
- extends java.lang.Object
- implements java.io.Serializable
This class encapsulates the String that is used to identify the subject that
a listener is interested in. Using plain Strings causes several severe problems:
- it's easy to misspell a subject, leading to undesired behaviour at runtime that is
hard to debug.
- in systems with many different subjects there is no safeguard for defining the
same subject twice for different purposes. This is especially true in a distributed
setting.
- See Also:
- Serialized Form
Constructor Summary |
protected |
EventSubject(java.lang.String fullSubjectName)
Protected constructor for new subjects. |
Method Summary |
boolean |
equals(java.lang.Object obj)
|
static EventSubject |
getSubject(java.lang.Class<?> subjectOwner,
java.lang.String subjectName)
Returns an event subject identified by the given owner and subject name. |
java.lang.String |
getSubjectName()
|
int |
hashCode()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
EventSubject
protected EventSubject(java.lang.String fullSubjectName)
- Protected constructor for new subjects.
- Parameters:
fullSubjectName
- the name of the new subject to be created
getSubject
public static EventSubject getSubject(java.lang.Class<?> subjectOwner,
java.lang.String subjectName)
- Returns an event subject identified by the given owner and subject name.
- Parameters:
subjectOwner
- the Class used for uniquely identifying this subjectsubjectName
- a String used as name, e.g. "MyEventTopic"
- Throws:
java.lang.IllegalArgumentException
- if subjectOwner/subjectName are null
or subjectName is empty.
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in class java.lang.Object
hashCode
public int hashCode()
- Overrides:
hashCode
in class java.lang.Object
getSubjectName
public java.lang.String getSubjectName()
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
- Returns:
- a String in the form
<ClassName 0x123456> SomeName
- See Also:
Object.toString()
Copyright © 2001-2012 Apache Cayenne. All Rights Reserved.