Skip to content

Commit cfc074b

Browse files
authored
Make segintersector.isDone() default to false (#1136)
1 parent 8a38124 commit cfc074b

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

modules/core/src/main/java/org/locationtech/jts/noding/SegmentIntersector.java

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,27 @@
1212
package org.locationtech.jts.noding;
1313

1414
/**
15+
* <p>
1516
* Processes possible intersections detected by a {@link Noder}.
16-
* The {@link SegmentIntersector} is passed to a {@link Noder}.
17-
* The {@link SegmentIntersector#processIntersections(SegmentString, int, SegmentString, int)} method is called whenever the {@link Noder}
18-
* detects that two SegmentStrings <i>might</i> intersect.
19-
* This class may be used either to find all intersections, or
20-
* to detect the presence of an intersection. In the latter case,
21-
* Noders may choose to short-circuit their computation by calling the
22-
* {@link #isDone()} method.
23-
* This class is an example of the <i>Strategy</i> pattern.
17+
* </p>
18+
*
19+
* <p>
20+
* A {@code SegmentIntersector} is passed to a {@link Noder}, and its
21+
* {@link #processIntersections(SegmentString, int, SegmentString, int)} method is called
22+
* whenever the {@code Noder} detects that two {@code SegmentString}s
23+
* <i>might</i> intersect.
24+
* </p>
25+
*
26+
* <p>
27+
* This interface can be used either to find all intersections, or to
28+
* simply detect the presence of an intersection. If only detection is needed,
29+
* implementations may short-circuit further computation by returning {@code true}
30+
* from the {@link #isDone()} method.
31+
* </p>
32+
*
33+
* <p>
34+
* This class is an example of the <i>Strategy</i> design pattern.
35+
* </p>
2436
*
2537
* @version 1.7
2638
*/
@@ -37,10 +49,19 @@ void processIntersections(
3749
);
3850

3951
/**
40-
* Reports whether the client of this class
41-
* needs to continue testing all intersections in an arrangement.
42-
*
43-
* @return true if there is no need to continue testing segments
52+
* Reports whether the client of this class needs to continue
53+
* testing all intersections in an arrangement.
54+
* <p>
55+
* By default, this method returns {@code false}, indicating that
56+
* all possible intersections will be processed.
57+
* Override this method to return {@code true} if you want
58+
* to short-circuit further processing (for example, once an intersection is found).
59+
* </p>
60+
*
61+
* @return {@code true} if there is no need to continue testing segments;
62+
* {@code false} to continue finding all intersections
4463
*/
45-
boolean isDone();
64+
default boolean isDone() {
65+
return false;
66+
}
4667
}

0 commit comments

Comments
 (0)