package org.sky.resource.rule.oss;

import org.sky.core.literule.annotation.LiteRuleComponent;
import org.sky.core.literule.core.RuleSwitchComponent;
import org.sky.resource.rule.context.OssContext;

import java.util.Collections;
import java.util.List;

import static org.sky.resource.rule.constant.OssRuleConstant.*;

/**
 * Oss缓存判断
 *
 */
@LiteRuleComponent(id = OSS_CACHE_RULE, name = "OSS缓存判断")
public class OssCacheRule extends RuleSwitchComponent {

	@Override
	public List<String> process() {
		OssContext contextBean = this.getContextBean(OssContext.class);
		// 若判断配置已缓存则直接读取，否则进入下一步构建新数据
		String ruleName = contextBean.getIsCached() ? OSS_READ_RULE : OSS_NEW_RULE;
		return Collections.singletonList(ruleName);
	}

}
