com._4dconcept.springframework.data.marklogic.MarklogicUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-data-marklogic Show documentation
Show all versions of spring-data-marklogic Show documentation
Marklogic support for Spring Data
package com._4dconcept.springframework.data.marklogic;
import com._4dconcept.springframework.data.marklogic.core.mapping.MarklogicPersistentEntity;
import com._4dconcept.springframework.data.marklogic.core.mapping.MarklogicPersistentProperty;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ParserContext;
import org.springframework.expression.common.LiteralExpression;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.util.StringUtils;
import java.util.function.Supplier;
/**
* Helper class featuring helper methods for working with Marklogic specific elements.
* Mainly intended for internal use within the framework.
*
* @author stoussaint
* @since 2017-11-30
*/
public final class MarklogicUtils {
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
/**
* Private constructor to prevent instantiation.
*/
private MarklogicUtils() {}
/**
* Expands the given expression using the provided type as context.
*
* @param expression the expression to expand
* @param entityType the entityType used as context
* @return the expanded expression. If the given expression is a literal or null, it is return as it.
*/
public static String expandsExpression(String expression, Class> entityType) {
return expandsExpression(expression, entityType, null, null);
}
/**
* Expands the given expression using the provided type, entity and id as context.
*
* @param expression the expression to expand
* @param entityType the entityType used as context
* @param entity the entity to use as context
* @return the expanded expression. If the given expression is a literal or null, it is return as it.
*/
public static String expandsExpression(String expression, Class> entityType, Object entity, Supplier