I'm using the JDO Query class and I need to conditionally pass certain parameters to the execute
method, as demonstrated in the code below.
I don't know how to do this in Java.
query.declareParameters("String alphaP");
query.declareParameters("String bravoP");
query.declareParameters("String charlieP");
if (condition == true)
{
if (othercondition == true)
{
query.declareParameters("List<String> stringList");
}
else
{
query.declareParameters("String simpleString");
}
}
if (someothercondition == true)
{
query.declareParameters("int deltaP");
}
if (yetanothercondition == true)
{
query.declareParameters("int echoP");
}
if (thelastcondition == true)
{
query.declareParameters("int foxtrotP");
}
List<ResultClass> results = (List<ResultClass>) query.execute(
alphaP,
bravoP,
charlieP,
... whatever other parameters are required based on which conditions are true above
);