I have an application server written in java that must use different machine learning models based on the request context. For example my request context looks like
class RequestContext {
String clientId;
String experimentId;
String sessionId;
...
}
Currently I have a delegation logic:
if(requestContext.experimentId == "experiment1"
&& requestContext.clientId == "client1"
){
// use model #1
} else if(requestContext.experimentId == "experiment2"
&& requestContext.clientId == "client1"){
// use model #2
} ...
I could use guava's predicates to express these rules and upon match, delegate to the appropriate model. As a second step, I would like to move these out of the server code to an external configuration store and have the server periodically read from it. This would enable me to not have to deploy server code each time I change the delegation rule. Moreover, I could write a UI that would let the business users define the conditions and the model to use.
My idea is to first specify a list of conditions that are available (in this case, clientId, experimentId, and sessionId) and allow the user to write a simple java-like script to create the conditions, for example one would write
clientId == "client1" && (sessionId != "session1" || experimentId == "experiment1")
then specify a model to use for when this condition is met. What library/techniques will help me parse a user specified predicate logic into a guava predicate-like object?