rspec/rules/S1470/flex/rule.adoc

49 lines
934 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
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
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,flex]
2021-04-28 16:49:39 +02:00
----
public class MyEvent extends Event {...}
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,flex]
2021-04-28 16:49:39 +02:00
----
public class MyEvent extends Event
{
...
override public function clone():Event {
return new MyEvent(...);
}
...
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]