Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utility methods for casting resources to their particular types #3239

Closed
vzhukovs opened this issue Dec 1, 2016 · 0 comments
Closed
Assignees
Labels
kind/task Internal things, technical debt, and to-do tasks to be performed.
Milestone

Comments

@vzhukovs
Copy link
Contributor

vzhukovs commented Dec 1, 2016

Add to org.eclipse.che.ide.api.resources.Resource interface utility methods to cast current resource to its particular type.

Proposed method names:

  • org.eclipse.che.ide.api.resources.Resource#asFile
  • org.eclipse.che.ide.api.resources.Resource#asFolder
  • org.eclipse.che.ide.api.resources.Resource#asProject

It's syntax sugar to better code readability.

Example of usage:

    public void doSmth() {

        Resource resource = ...;
        
        if (resource.isFolder()) {
            final Folder folder = resource.asFolder();
            
            folder.newFile("name", "content");
        }
        
    }

If resource type is not corresponding caller method, method should throw java.lang.IllegalStateException

@vzhukovs vzhukovs added kind/task Internal things, technical debt, and to-do tasks to be performed. status/open-for-dev An issue has had its specification reviewed and confirmed. Waiting for an engineer to take it. team/plugin labels Dec 1, 2016
@vzhukovs vzhukovs self-assigned this Dec 1, 2016
@vzhukovs vzhukovs removed the status/open-for-dev An issue has had its specification reviewed and confirmed. Waiting for an engineer to take it. label Jan 11, 2017
@vzhukovs vzhukovs added this to the 5.1.0 milestone Jan 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/task Internal things, technical debt, and to-do tasks to be performed.
Projects
None yet
Development

No branches or pull requests

1 participant