@Test public void testMerge() { SecurityAnalysisResult[] results = new SecurityAnalysisResult[]{ result1, result2 }; SecurityAnalysisResult mergedResult = SecurityAnalysisResultMerger.merge(results); assertEquals(preContingencyResult, mergedResult.getPreContingencyResult()); assertEquals(Arrays.asList(postContingencyResult, postContingencyResult2), mergedResult.getPostContingencyResults()); }
public static SecurityAnalysisResult merge(SecurityAnalysisResult[] results) { Objects.requireNonNull(results); for (SecurityAnalysisResult subResult : results) { if (!subResult.getPreContingencyResult().isComputationOk()) { return FAILED_SECURITY_ANALYSIS_RESULT; } } final SecurityAnalysisResult res = new SecurityAnalysisResult( results[0].getPreContingencyResult(), new ArrayList<>(results[0].getPostContingencyResults())) .setNetworkMetadata(results[0].getNetworkMetadata()); if (results.length > 1) { Arrays.stream(results, 1, results.length).forEach(r -> res.getPostContingencyResults().addAll(r.getPostContingencyResults())); } return res; }
SecurityAnalysisResultMerger { public static SecurityAnalysisResult merge(SecurityAnalysisResult[] results) { Objects.requireNonNull(results); for (SecurityAnalysisResult subResult : results) { if (!subResult.getPreContingencyResult().isComputationOk()) { return FAILED_SECURITY_ANALYSIS_RESULT; } } final SecurityAnalysisResult res = new SecurityAnalysisResult( results[0].getPreContingencyResult(), new ArrayList<>(results[0].getPostContingencyResults())) .setNetworkMetadata(results[0].getNetworkMetadata()); if (results.length > 1) { Arrays.stream(results, 1, results.length).forEach(r -> res.getPostContingencyResults().addAll(r.getPostContingencyResults())); } return res; } }
SecurityAnalysisResultMerger { public static SecurityAnalysisResult merge(SecurityAnalysisResult[] results) { Objects.requireNonNull(results); for (SecurityAnalysisResult subResult : results) { if (!subResult.getPreContingencyResult().isComputationOk()) { return FAILED_SECURITY_ANALYSIS_RESULT; } } final SecurityAnalysisResult res = new SecurityAnalysisResult( results[0].getPreContingencyResult(), new ArrayList<>(results[0].getPostContingencyResults())) .setNetworkMetadata(results[0].getNetworkMetadata()); if (results.length > 1) { Arrays.stream(results, 1, results.length).forEach(r -> res.getPostContingencyResults().addAll(r.getPostContingencyResults())); } return res; } private  SecurityAnalysisResultMerger(); }
SecurityAnalysisResultMerger { public static SecurityAnalysisResult merge(SecurityAnalysisResult[] results) { Objects.requireNonNull(results); for (SecurityAnalysisResult subResult : results) { if (!subResult.getPreContingencyResult().isComputationOk()) { return FAILED_SECURITY_ANALYSIS_RESULT; } } final SecurityAnalysisResult res = new SecurityAnalysisResult( results[0].getPreContingencyResult(), new ArrayList<>(results[0].getPostContingencyResults())) .setNetworkMetadata(results[0].getNetworkMetadata()); if (results.length > 1) { Arrays.stream(results, 1, results.length).forEach(r -> res.getPostContingencyResults().addAll(r.getPostContingencyResults())); } return res; } private  SecurityAnalysisResultMerger(); static SecurityAnalysisResult merge(SecurityAnalysisResult[] results); static SecurityAnalysisResult merge(Collection<SecurityAnalysisResult> results); }
SecurityAnalysisResultMerger { public static SecurityAnalysisResult merge(SecurityAnalysisResult[] results) { Objects.requireNonNull(results); for (SecurityAnalysisResult subResult : results) { if (!subResult.getPreContingencyResult().isComputationOk()) { return FAILED_SECURITY_ANALYSIS_RESULT; } } final SecurityAnalysisResult res = new SecurityAnalysisResult( results[0].getPreContingencyResult(), new ArrayList<>(results[0].getPostContingencyResults())) .setNetworkMetadata(results[0].getNetworkMetadata()); if (results.length > 1) { Arrays.stream(results, 1, results.length).forEach(r -> res.getPostContingencyResults().addAll(r.getPostContingencyResults())); } return res; } private  SecurityAnalysisResultMerger(); static SecurityAnalysisResult merge(SecurityAnalysisResult[] results); static SecurityAnalysisResult merge(Collection<SecurityAnalysisResult> results); static final SecurityAnalysisResult FAILED_SECURITY_ANALYSIS_RESULT; }