package com.sptg.common.tag.dialect;

import com.sptg.common.tag.processor.CustomSessionIdTagProcessor;
import com.sptg.common.tag.processor.SecurityTagProcessor;
import org.thymeleaf.dialect.AbstractProcessorDialect;
import org.thymeleaf.processor.IProcessor;

import java.util.LinkedHashSet;
import java.util.Set;

/**
 * title: CustomDialect
 * package: com.sptg.common.tag.dialect
 * description: 自定义方言
 *
 *                  
 *                 
 */
public class CustomDialect extends AbstractProcessorDialect {

    private static final String NAME = "Standard";
    private static final String PREFIX = "sptg";
    private static final int PROCESSOR_PRECEDENCE = 1000;

    public CustomDialect(){
        super(NAME,PREFIX,PROCESSOR_PRECEDENCE);
    }

    @Override
    public Set<IProcessor> getProcessors(String dialectPrefix) {
        return CustomDialect.createStandardProcessorsSet(dialectPrefix);
    }

    private static Set<IProcessor> createStandardProcessorsSet(final String dialectPrefix){
        final Set<IProcessor> processors = new LinkedHashSet<>();
        processors.add(new CustomSessionIdTagProcessor(dialectPrefix));
        processors.add(new SecurityTagProcessor(dialectPrefix));
        return processors;
    }

}
