Bug 540535 - Introduce DefaultEditorUtility
Summary: Introduce DefaultEditorUtility
Status: RESOLVED FIXED
Alias: None
Product: Handly
Classification: Technology
Component: UI (show other bugs)
Version: 1.1   Edit
Hardware: All All
: P3 enhancement
Target Milestone: 1.1   Edit
Assignee: Vladimir Piskarev CLA
QA Contact:
URL:
Whiteboard: breakingchange
Keywords: api
Depends on:
Blocks:
 
Reported: 2018-10-27 11:06 EDT by Vladimir Piskarev CLA
Modified: 2018-10-27 11:29 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Piskarev CLA 2018-10-27 11:06:59 EDT
Currently, clients can create a new instance of the class EditorUtility or use the shared  instance called DEFAULT, which is a public static final field in EditorUtility. The problem with the DEFAULT field is that the EditorUtility is not a final class and may be subclassed by clients.

For example, we could create a Java-specific extension:

public class JavaEditorUtility extends EditorUtility {
    public static final EditorUtility INSTANCE = new JavaEditorUtility();
...
}

In this case, the class JavaEditorUtility would expose two public static final fields INSTANCE and DEFAULT of the type EditorUtility, which could be confusing for clients:

JavaEditorUtility.INSTANCE // an instance of JavaEditorUtility
JavaEditorUtility.DEFAULT  // NOT an instance of JavaEditorUtility

A better alternative might be to introduce a separate class, DefaultEditorUtility, which would provide the default instance of the editor utility, and to remove the DEFAULT field from the EditorUtility. Note that this is a breaking change.
Comment 1 Vladimir Piskarev CLA 2018-10-27 11:29:38 EDT
Pushed to master:
http://git.eclipse.org/c/handly/org.eclipse.handly.git/commit/?id=9f87ec119774d5cd72400eda33e38f3af993682a

Breaking changes:

* EditorUtility.DEFAULT has been replaced with DefaultEditorUtility.INSTANCE

* EditorUtility constructor is now protected (was public) to prevent direct instantiation by clients