protected boolean doCheck()

in trusty/trusty-service/trusty-service-common/src/main/java/org/kie/kogito/trusty/service/common/CounterfactualParameterValidation.java [66:102]


        protected boolean doCheck(Collection<StructureHolder<CV>> normalisedStructure1,
                Collection<StructureHolder<DV>> normalisedStructure2) {
            if (Objects.isNull(normalisedStructure1) && Objects.isNull(normalisedStructure2)) {
                return true;
            }
            if (Objects.isNull(normalisedStructure1)) {
                return false;
            }
            if (Objects.isNull(normalisedStructure2)) {
                return false;
            }
            if (normalisedStructure1.isEmpty() && normalisedStructure2.isEmpty()) {
                return true;
            }

            Map<String, StructureHolder<CV>> structure1Map = normalisedStructure1.stream().collect(Collectors.toMap(ih -> ih.name, ih -> ih));
            Map<String, StructureHolder<DV>> structure2Map = normalisedStructure2.stream().collect(Collectors.toMap(ih -> ih.name, ih -> ih));
            if (!checkMembership(structure1Map, structure2Map)) {
                return false;
            }

            //Check direct descendents
            Collection<StructureHolder<CV>> structure1ChildStructures =
                    structure1Map.values()
                            .stream()
                            .map(ih -> getChildrenOfStructure1(ih.original))
                            .flatMap(Collection::stream)
                            .collect(Collectors.toList());
            Collection<StructureHolder<DV>> structure2ChildStructures =
                    structure2Map.values()
                            .stream()
                            .map(ih -> getChildrenOfStructure2(ih.original))
                            .flatMap(Collection::stream)
                            .collect(Collectors.toList());

            return doCheck(structure1ChildStructures, structure2ChildStructures);
        }