File tree Expand file tree Collapse file tree 13 files changed +136
-4
lines changed Expand file tree Collapse file tree 13 files changed +136
-4
lines changed Original file line number Diff line number Diff line change
1
+ package filters ;
2
+
3
+ import twitter4j .Status ;
4
+
5
+ import java .util .ArrayList ;
6
+ import java .util .List ;
7
+
8
+ /**
9
+ * A filter that represents the logical not of its child0 filter
10
+ */
11
+ public class AndFilter implements Filter {
12
+
13
+ private final Filter child0 ;
14
+ private final Filter child1 ;
15
+
16
+
17
+ public AndFilter (Filter child , Filter child1 ) {
18
+ this .child0 = child ;
19
+ this .child1 = child1 ;
20
+ }
21
+
22
+ /**
23
+ * @param s0 the tweet to check
24
+ * @param s1 the next tweet to check
25
+ * @return 2 status are matches
26
+ */
27
+ public boolean matches (Status s0 , Status s1 ) {
28
+ return child0 .matches (s0 ) && child1 .matches (s1 ) || child0 .matches (s1 ) && child1 .matches (s0 );
29
+ }
30
+
31
+ @ Override
32
+ public boolean matches (Status s ) {
33
+ return false ;
34
+ }
35
+
36
+ @ Override
37
+ public List <String > terms () {
38
+ return child0 .terms ();
39
+ }
40
+
41
+ public List <String > andTerms () {
42
+ ArrayList <String > terms = new ArrayList <>();
43
+ terms .add (String .valueOf (child0 .terms ()));
44
+ terms .add (String .valueOf (child1 .terms ()));
45
+ return terms ;
46
+ }
47
+
48
+ public String toString () {
49
+ return child1 .toString () + " and " + child0 .toString ();
50
+ }
51
+ }
Original file line number Diff line number Diff line change
1
+ package filters ;
2
+
3
+ import twitter4j .Status ;
4
+
5
+ import java .util .ArrayList ;
6
+ import java .util .List ;
7
+
8
+ /**
9
+ * A filter that represents the logical not of its child0 filter
10
+ */
11
+ public class OrFilter implements Filter {
12
+
13
+ private final Filter child0 ;
14
+ private final Filter child1 ;
15
+
16
+
17
+ public OrFilter (Filter child , Filter child1 ) {
18
+ this .child0 = child ;
19
+ this .child1 = child1 ;
20
+ }
21
+
22
+ /**
23
+ * A and filter matches when its child0 doesn't, and vice versa
24
+ * @param s0 the tweet to check
25
+ * @param s1 the next tweet to check
26
+ * @return whether or not it matches
27
+ */
28
+ public boolean matches (Status s0 , Status s1 ) {
29
+ return (child0 .matches (s0 ) || child1 .matches (s1 )) || (child0 .matches (s1 ) || child1 .matches (s0 ));
30
+ }
31
+
32
+ @ Override
33
+ public boolean matches (Status s ) {
34
+ return false ;
35
+ }
36
+
37
+ @ Override
38
+ public List <String > terms () {
39
+ return child0 .terms ();
40
+ }
41
+
42
+ public List <String > orTerms () {
43
+ ArrayList <String > terms = new ArrayList <>();
44
+ terms .add (String .valueOf (child0 .terms ()));
45
+ terms .add (String .valueOf (child1 .terms ()));
46
+ return terms ;
47
+ }
48
+
49
+ public String toString () {
50
+ return child1 .toString () + " or " + child0 .toString ();
51
+ }
52
+ }
You can’t perform that action at this time.
0 commit comments