org.datanucleus.api.jdo.query.IfThenElseExpressionImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datanucleus-api-jdo Show documentation
Show all versions of datanucleus-api-jdo Show documentation
Plugin providing DataNucleus implementation of the JDO API.
/**********************************************************************
Copyright (c) 2018 Andy Jefferson and others. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Contributors:
...
**********************************************************************/
package org.datanucleus.api.jdo.query;
import javax.jdo.query.BooleanExpression;
import javax.jdo.query.Expression;
import javax.jdo.query.IfThenElseExpression;
import org.datanucleus.store.query.expression.CaseExpression;
import org.datanucleus.store.query.expression.Literal;
/**
* Implementation of an IfThenElseExpression.
* Generates an underlying generic CaseExpression.
*/
public class IfThenElseExpressionImpl extends ComparableExpressionImpl implements IfThenElseExpression
{
CaseExpression caseExpr = null;
public IfThenElseExpressionImpl()
{
super(new CaseExpression());
caseExpr = (CaseExpression) queryExpr;
}
/* (non-Javadoc)
* @see javax.jdo.query.IfThenElseExpression#when(javax.jdo.query.BooleanExpression, java.lang.Object)
*/
@Override
public IfThenElseExpression ifThen(BooleanExpression ifExpr, T value)
{
caseExpr.addCondition(((BooleanExpressionImpl)ifExpr).getQueryExpression(), new Literal(value));
return this;
}
/* (non-Javadoc)
* @see javax.jdo.query.IfThenElseExpression#when(javax.jdo.query.BooleanExpression, javax.jdo.query.Expression)
*/
@Override
public IfThenElseExpression ifThen(BooleanExpression ifExpr, Expression valueExpr)
{
caseExpr.addCondition(((BooleanExpressionImpl)ifExpr).getQueryExpression(), ((ExpressionImpl)valueExpr).getQueryExpression());
return this;
}
/* (non-Javadoc)
* @see javax.jdo.query.IfThenElseExpression#otherwise(java.lang.Object)
*/
@Override
public IfThenElseExpression elseEnd(T value)
{
caseExpr.setElseExpression(new Literal(value));
return this;
}
/* (non-Javadoc)
* @see javax.jdo.query.IfThenElseExpression#otherwise(javax.jdo.query.Expression)
*/
@Override
public IfThenElseExpression elseEnd(Expression valueExpr)
{
caseExpr.setElseExpression(((ExpressionImpl)valueExpr).getQueryExpression());
return this;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy