Package org.apache.cayenne.event
Class EventSubject
- java.lang.Object
-
- org.apache.cayenne.event.EventSubject
-
- All Implemented Interfaces:
Serializable
public class EventSubject extends Object implements 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
Constructors Modifier Constructor Description protected
EventSubject(String fullSubjectName)
Protected constructor for new subjects.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
static EventSubject
getSubject(Class<?> subjectOwner, String subjectName)
Returns an event subject identified by the given owner and subject name.String
getSubjectName()
int
hashCode()
String
toString()
-
-
-
Constructor Detail
-
EventSubject
protected EventSubject(String fullSubjectName)
Protected constructor for new subjects.- Parameters:
fullSubjectName
- the name of the new subject to be created
-
-
Method Detail
-
getSubject
public static EventSubject getSubject(Class<?> subjectOwner, 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:
IllegalArgumentException
- if subjectOwner/subjectName arenull
or subjectName is empty.
-
getSubjectName
public String getSubjectName()
-
toString
public String toString()
- Overrides:
toString
in classObject
- Returns:
- a String in the form
<ClassName 0x123456> SomeName
- See Also:
Object.toString()
-
-