-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize list of material filters (#1464)
Signed-off-by: Pablo Herrera <[email protected]>
- Loading branch information
1 parent
4428b14
commit 5803438
Showing
13 changed files
with
124 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
core/src/main/java/tc/oc/pgm/filters/operator/FilterWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package tc.oc.pgm.filters.operator; | ||
|
||
import org.jdom2.Element; | ||
import tc.oc.pgm.api.feature.FeatureReference; | ||
import tc.oc.pgm.api.filter.Filter; | ||
import tc.oc.pgm.api.filter.query.Query; | ||
|
||
/** | ||
* Wrapper around a child filter, exists only as a parsing optimization. Single-child "any", "all" | ||
* or "one" filters can often be replaced with their single child, but when the child is a | ||
* reference, they can instead be turned into a wrapped filter. <br> | ||
* For example, {@code <all id="outer"><region id="other"/></all>}. Because the child is a | ||
* reference, if we simplified parsing to returning "other", pgm wouldn't register it under the | ||
* "outer" name (you can't register a reference, otherwise it creates duplicates). For those cases, | ||
* we create a filter wrapper around "other", and return that instead. | ||
*/ | ||
public class FilterWrapper extends SingleFilterFunction { | ||
|
||
private FilterWrapper(Filter filter) { | ||
super(filter); | ||
} | ||
|
||
@Override | ||
public QueryResponse query(Query query) { | ||
return filter.query(query); | ||
} | ||
|
||
public static Filter of(Element el, Filter filter) { | ||
if (el.getAttribute("id") == null || !(filter instanceof FeatureReference<?>)) return filter; | ||
return new FilterWrapper(filter); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters