Skip to content

Commit 75b25d7

Browse files
committed
refactored contains towards more expression like looking
1 parent f91a4f4 commit 75b25d7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/net/itarray/automotion/internal/UIElement.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.itarray.automotion.internal.geometry.Rectangle;
88
import net.itarray.automotion.internal.geometry.Scalar;
99
import net.itarray.automotion.internal.geometry.Vector;
10+
import net.itarray.automotion.internal.properties.ConstantExpression;
1011
import net.itarray.automotion.internal.properties.Context;
1112
import net.itarray.automotion.tools.general.SystemHelper;
1213
import net.itarray.automotion.tools.helpers.TextFinder;
@@ -223,11 +224,11 @@ private static String getShortenedText(String text) {
223224

224225
public boolean contains(UIElement other, Context context) {
225226
return
226-
Condition.lessOrEqualTo(other.getLeft()).isSatisfiedOn(getLeft(), context, RIGHT) &&
227-
Condition.lessOrEqualTo(getRight()).isSatisfiedOn(other.getRight(), context, RIGHT) &&
228-
Condition.lessOrEqualTo(other.getTop()).isSatisfiedOn(getTop(), context, DOWN) &&
229-
Condition.lessOrEqualTo(getBottom()).isSatisfiedOn(other.getBottom(), context, DOWN);
230-
}
227+
Condition.lessOrEqualTo(other.end(LEFT)).applyTo(end(LEFT)).evaluateIn(context, RIGHT) &&
228+
Condition.lessOrEqualTo(end(RIGHT)).applyTo(other.end(RIGHT)).evaluateIn(context, RIGHT) &&
229+
Condition.lessOrEqualTo(other.end(UP)).applyTo(end(UP)).evaluateIn(context, DOWN) &&
230+
Condition.lessOrEqualTo(end(DOWN)).applyTo(other.end(DOWN)).evaluateIn(context, DOWN);
231+
}
231232

232233
public void validateLeftAlignedWith(UIElement element, Context context) {
233234
validateEqualEnd(LEFT, element, context);

0 commit comments

Comments
 (0)