Skip to content
Snippets Groups Projects
Commit c2d427a5 authored by Simon Barner's avatar Simon Barner
Browse files

Make get(0) safe and document it.

parent 610a66f1
No related branches found
No related tags found
No related merge requests found
......@@ -42,7 +42,7 @@ import org.osgi.framework.Bundle;
* @author barner
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 9B5AB77EC13C4D7553AEF2AF60CA06D7
* @ConQAT.Rating YELLOW Hash: 1EB8B12E46C5D4738A9D552205E56A0B
*/
public abstract class EcoreSerializerBase<R extends EObject> {
......@@ -111,6 +111,10 @@ public abstract class EcoreSerializerBase<R extends EObject> {
ResourceSet resourceSet = createResourceSet();
Resource resource = resourceSet.getResource(uri, true);
if(resource.getContents().isEmpty()) {
return null;
}
// get(0) is guaranteed to be safe
return getRootElement(resource.getContents().get(0));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment