-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #437 from com-pas/436-add-connectedapservice-and-s…
…ubnetworkservice feat(#436): Add ConnectedAPService and SubnetworkService
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ConnectedAPService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.TConnectedAP; | ||
import org.lfenergy.compas.scl2007b4.model.TSubNetwork; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
public class ConnectedAPService { | ||
|
||
public Stream<TConnectedAP> getConnectedAP(TSubNetwork tSubNetwork) { | ||
if (!tSubNetwork.isSetConnectedAP()) { | ||
return Stream.empty(); | ||
} | ||
return tSubNetwork.getConnectedAP().stream(); | ||
} | ||
|
||
public Stream<TConnectedAP> getFilteredConnectedAP(TSubNetwork tSubNetwork, Predicate<TConnectedAP> tConnectedAPPredicate) { | ||
return getConnectedAP(tSubNetwork).filter(tConnectedAPPredicate); | ||
} | ||
|
||
public Optional<TConnectedAP> findConnectedAP(TSubNetwork tSubNetwork, Predicate<TConnectedAP> tConnectedAPPredicate) { | ||
return getFilteredConnectedAP(tSubNetwork, tConnectedAPPredicate).findFirst(); | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
sct-commons/src/main/java/org/lfenergy/compas/sct/commons/SubNetworkService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons; | ||
|
||
import org.lfenergy.compas.scl2007b4.model.TSubNetwork; | ||
import org.lfenergy.compas.scl2007b4.model.SCL; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
public class SubNetworkService { | ||
|
||
public Stream<TSubNetwork> getSubNetworks(SCL scl) { | ||
if (!scl.isSetCommunication()) { | ||
return Stream.empty(); | ||
} | ||
if (!scl.getCommunication().isSetSubNetwork()) { | ||
return Stream.empty(); | ||
} | ||
return scl.getCommunication().getSubNetwork().stream(); | ||
} | ||
|
||
public Stream<TSubNetwork> getFilteredSubNetworks(SCL tlNodeType, Predicate<TSubNetwork> tdoPredicate) { | ||
return getSubNetworks(tlNodeType).filter(tdoPredicate); | ||
} | ||
|
||
public Optional<TSubNetwork> findSubNetwork(SCL tlNodeType, Predicate<TSubNetwork> tdoPredicate) { | ||
return getFilteredSubNetworks(tlNodeType, tdoPredicate).findFirst(); | ||
} | ||
|
||
} |