All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.livk.commons.expression.ConverterExpressionResolver Maven / Gradle / Ivy

/*
 * Copyright 2021-2024 spring-boot-extension the original author or authors.
 *
 * 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
 *
 *       https://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.
 */

package com.livk.commons.expression;

import org.springframework.util.Assert;

/**
 * The type Converter expression resolver.
 *
 * @param  the type parameter
 * @param  the type parameter
 * @author livk
 * @see com.livk.commons.expression.jexl3.JexlExpressionResolver
 * @see com.livk.commons.expression.mvel2.MvelExpressionResolver
 * @see com.livk.commons.expression.spring.SpringExpressionResolver
 */
public abstract class ConverterExpressionResolver extends CacheExpressionResolver {

	@Override
	protected final  T calculate(E expression, Context context, Class returnType) {
		C frameworkContext = transform(context);
		Assert.notNull(frameworkContext, "frameworkContext not be null");
		return calculate(expression, frameworkContext, returnType);
	}

	/**
	 * 从Context装换成框架的上下文
	 * @param context context
	 * @return the c
	 */
	protected abstract C transform(Context context);

	/**
	 * 对表达式进行计算
	 * @param  泛型
	 * @param expression 表达式
	 * @param context 上下文
	 * @param returnType 返回类型
	 * @return 计算结果相关实例
	 */
	protected abstract  T calculate(E expression, C context, Class returnType);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy