16
16
import java .util .List ;
17
17
import java .util .Objects ;
18
18
import java .util .Optional ;
19
+ import java .util .function .Predicate ;
19
20
import java .util .stream .Stream ;
20
21
21
22
public class ExtRefService {
22
23
23
24
/**
24
25
* List all ExtRefs in this LDevice
25
26
*
26
- * @return list of ExtRefs. List is modifiable.
27
+ * @return Stream of ExtRefs
27
28
*/
28
29
public Stream <TExtRef > getExtRefs (TLDevice tlDevice ) {
29
30
return getInputs (tlDevice )
@@ -32,6 +33,16 @@ public Stream<TExtRef> getExtRefs(TLDevice tlDevice) {
32
33
.flatMap (tInputs -> tInputs .getExtRef ().stream ());
33
34
}
34
35
36
+ /**
37
+ * List ExtRefs in this LDevice that satisfy the given predicate
38
+ *
39
+ * @return Stream of ExtRefs.
40
+ */
41
+ public Stream <TExtRef > getFilteredExtRefs (TLDevice tlDevice , Predicate <TExtRef > tExtRefPredicate ) {
42
+ return getExtRefs (tlDevice )
43
+ .filter (tExtRefPredicate );
44
+ }
45
+
35
46
/**
36
47
* Debind ExtRef
37
48
*
@@ -61,8 +72,8 @@ public void clearExtRefBinding(TExtRef extRef) {
61
72
* @return true if the two ExtRef are fed by same Control Block, otherwise false
62
73
*/
63
74
public boolean isExtRefFeedBySameControlBlock (TExtRef t1 , TExtRef t2 ) {
64
- String srcLNClass1 = (t1 .isSetSrcLNClass ()) ? t1 .getSrcLNClass ().get ( 0 ) : TLLN0Enum .LLN_0 .value ();
65
- String srcLNClass2 = (t2 .isSetSrcLNClass ()) ? t2 .getSrcLNClass ().get ( 0 ) : TLLN0Enum .LLN_0 .value ();
75
+ String srcLNClass1 = (t1 .isSetSrcLNClass ()) ? t1 .getSrcLNClass ().getFirst ( ) : TLLN0Enum .LLN_0 .value ();
76
+ String srcLNClass2 = (t2 .isSetSrcLNClass ()) ? t2 .getSrcLNClass ().getFirst ( ) : TLLN0Enum .LLN_0 .value ();
66
77
return Utils .equalsOrBothBlank (t1 .getIedName (), t2 .getIedName ())
67
78
&& Utils .equalsOrBothBlank (t1 .getSrcLDInst (), t2 .getSrcLDInst ())
68
79
&& srcLNClass1 .equals (srcLNClass2 )
0 commit comments