Last active
August 16, 2017 09:58
-
-
Save nbhusare/f27e1e6043863b3bb0d1dbb498f6c89e to your computer and use it in GitHub Desktop.
Safe way of adding resource to the resource set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the URI to the resource | |
final URI uri = resource.getURI(); | |
// Get the resource resolved by the URI. Do not load the resource, only get one if exists | |
final Resource r = resourceSet.getResource(uri, false); | |
if (r != null) { | |
// Add the resource to the resourceset | |
resourceSet.getResources().add(resource); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment