diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java index fc704572f..79b6d2814 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java @@ -36,7 +36,7 @@ public class ASTFactory { List methoden = new ArrayList<>(); List konstruktoren = new ArrayList<>(); for(java.lang.reflect.Constructor constructor : jreClass.getConstructors()){ - konstruktoren.add(createConstructor(constructor, jreClass)); + createConstructor(constructor, jreClass).map(c -> konstruktoren.add(c)); } Set allMethods = new HashSet<>(Arrays.asList(jreClass.getMethods())); Set allDeclaredMethods = new HashSet<>(Arrays.asList(jreClass.getDeclaredMethods())); @@ -87,7 +87,7 @@ public class ASTFactory { // return createClass(classType).getType(); //} - private static de.dhbwstuttgart.syntaxtree.Constructor createConstructor(Constructor constructor, Class inClass) { + private static Optional createConstructor(Constructor constructor, Class inClass) { String name = constructor.getName(); RefTypeOrTPHOrWildcardOrGeneric returnType = createType(inClass); Parameter[] jreParams = constructor.getParameters(); @@ -106,10 +106,10 @@ public class ASTFactory { int modifier = constructor.getModifiers(); if(inClass.equals(java.lang.Object.class)){ - return null; + return Optional.empty(); } - return new de.dhbwstuttgart.syntaxtree.Constructor(modifier, name,returnType, parameterList, block, gtvDeclarations, offset /*, new ArrayList<>() geloescht PL 2018-11-24 */); + return Optional.of(new de.dhbwstuttgart.syntaxtree.Constructor(modifier, name,returnType, parameterList, block, gtvDeclarations, offset /*, new ArrayList<>() geloescht PL 2018-11-24 */)); } public static Method createMethod(java.lang.reflect.Method jreMethod, java.lang.Class inClass, Boolean isInherited){