Commit 80ed8ba 1 parent 4867f4c commit 80ed8ba Copy full SHA for 80ed8ba
File tree 2 files changed +24
-0
lines changed
fundamentals/fundamentals-platform/src
main/scala/izumi/fundamentals/platform/strings
test/scala/izumi/fundamentals/platform
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,19 @@ object TextTree {
67
67
}
68
68
}
69
69
70
+ def isEmpty : Boolean = {
71
+ target match {
72
+ case _ : ValueNode [T ] => false
73
+ case s : StringNode => s.value.isEmpty
74
+ case s : Shift [T ] => s.nested.isEmpty
75
+ case t : Trim [T ] => t.nested.isEmpty
76
+ case n : Node [T ] =>
77
+ n.chunks.forall(_.isEmpty)
78
+ }
79
+ }
80
+
81
+ def nonEmpty : Boolean = ! isEmpty
82
+
70
83
def flatten : TextTree [T ] = {
71
84
target match {
72
85
case v : ValueNode [T ] => Node (NEList (v))
Original file line number Diff line number Diff line change @@ -99,6 +99,17 @@ class TextTreeTest extends AnyWordSpec {
99
99
accept(t5)
100
100
}
101
101
}
102
+
103
+ " support emptiness check" in {
104
+ val q1 = q " "
105
+ val q2 = q " $q1"
106
+ val q3 = q " x $q1"
107
+
108
+ assert(q1.isEmpty)
109
+ assert(q2.isEmpty)
110
+ assert(q3.nonEmpty)
111
+
112
+ }
102
113
}
103
114
}
104
115
You can’t perform that action at this time.
0 commit comments