Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6c46a1
commit 697e28c
Showing
8 changed files
with
253 additions
and
98 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
gs-api/src/main/java/org/genericsystem/api/core/Filters.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,31 @@ | ||
package org.genericsystem.api.core; | ||
|
||
import java.util.function.Function; | ||
|
||
public enum Filters { | ||
|
||
INSTANCES(vertex -> (x -> vertex.equals(x.getMeta()))), INHERITINGS(vertex -> (x -> x.getSupers().contains(vertex))), COMPOSITES(vertex -> (x -> x.getComponents().contains(vertex))); | ||
|
||
private Function<IGeneric<?>, IndexFilter> getFilter; | ||
|
||
Filters(Function<IGeneric<?>, IndexFilter> getFilter) { | ||
this.getFilter = getFilter; | ||
} | ||
|
||
public <T extends IGeneric<T>> IndexFilter getFilter(T generic) { | ||
return getFilter.apply(generic); | ||
} | ||
|
||
public static interface IndexFilter<T extends IGeneric<T>> { | ||
boolean test(T generic); | ||
} | ||
|
||
public static NoFilter<?> NO_FILTER = new NoFilter<>(); | ||
|
||
public static class NoFilter<T extends IGeneric<T>> implements IndexFilter<T> { | ||
@Override | ||
public boolean test(T generic) { | ||
return true; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.