I use a custom access layer (not relational, not standardized in any way) which is in the form of a jar file, like an API. This access layer provides a custom way to filter the results when I ask a "query". I wrap this custom data access layer using the Repository design pattern, following a design similar to the one described here, in order to hide its complexity to the above layers.
Therefore, one of my repository's functions to execute queries would be something like the one following:
public class Repository {
// Other methods...
public Set<CustomEntity> get(Predicate<CustomEntity> predicate) {
// code calling the wrapped custom access layer
}
// Other methods...
}
A typical call of the above method would be something like
Set<CustomEntity> queryResults = customEntitiesRepository.get(
p -> p.property1 == "criterio 1" && p.property2 == "criterio 2"
);
Obviously, the method get
would translate the predicate
with two criteria in the custom access layer's filtering mechanism. However, I don't know how to retrieve the content of the predicate
in order to apply the filters to the custom access layer. Is there such a mechanism? Is it feasible to use reflection API or something like that in order to retrieve a predicate's conditions?
Aucun commentaire:
Enregistrer un commentaire