Added helper method to lookup for inverse relations regardless of the upper/lower case in the relation encoding

This commit is contained in:
Claudio Atzori 2021-12-06 10:10:36 +01:00
parent 25107cbb20
commit 3cd16d6bb1
1 changed files with 15 additions and 0 deletions

View File

@ -158,6 +158,21 @@ public class ModelSupport {
}
}
/**
* Helper method: lookup relation inverse, given the direct relation encoding (case insensitive)
* @param encoding
* @return the relation inverse descriptor, throws @IllegalArgumentException when not found.
*/
private RelationInverse findInverse(String encoding) {
return ModelSupport.relationInverseMap
.entrySet()
.stream()
.filter(r -> encoding.equalsIgnoreCase(r.getKey()))
.findFirst()
.map(r -> r.getValue())
.orElseThrow(() -> new IllegalArgumentException("invalid relationship: " + encoding));
}
/**
* Helper method: fina a relation filtering by a relation name
* @param relationName