30 lines
626 B
Plaintext
30 lines
626 B
Plaintext
Overriding Event.clone() is a required part of the API contract:
|
|
|
|
____
|
|
You are required to override the Event.clone() method in your Event subclass. The clone() method returns a cloned copy of the event object by setting the type property and any new properties in the clone. Typically, you define the clone() method to return an event instance created with the new operator.
|
|
|
|
____
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
public class MyEvent extends Event {...}
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
public class MyEvent extends Event
|
|
{
|
|
...
|
|
override public function clone():Event {
|
|
return new MyEvent(...);
|
|
}
|
|
...
|
|
}
|
|
----
|
|
|
|
|