Skip to content
Snippets Groups Projects
Commit 190c454a authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Fix NPE in getParentElement(...): Return null if input EObject is null;...

Fix NPE in getParentElement(...): Return null if input EObject is null; Otherwise NPE occurs if isReflexive == false.
parent 156ee368
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 32720C522B09A28636B9A53913B5B753
* @ConQAT.Rating YELLOW Hash: 9163DE286C9C7E95192F7149338E95BE
*/
public final class KernelModelElementUtils {
......@@ -121,6 +121,9 @@ public final class KernelModelElementUtils {
@SuppressWarnings("unchecked")
public static <T extends EObject> T getParentElement(EObject element, Class<T> targetClass,
boolean isReflexive) {
if(element == null) {
return null;
}
EObject currentParent = isReflexive ? element : element.eContainer();
while(currentParent != null && !(targetClass.isAssignableFrom(currentParent.getClass()))) {
currentParent = currentParent.eContainer();
......
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