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

com.astamuse.asta4d.web.dispatch.mapping.handy.base.AttrConfigurableRule Maven / Gradle / Ivy

Go to download

web functionalities of asta4d framework, including view first and url matching

The newest version!
package com.astamuse.asta4d.web.dispatch.mapping.handy.base;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.astamuse.asta4d.web.dispatch.DispatcherRuleMatcher;
import com.astamuse.asta4d.web.dispatch.mapping.UrlMappingRuleSet;

@SuppressWarnings({ "unchecked", "rawtypes" })
public interface AttrConfigurableRule extends HandyRuleConfigurable {

    default T priority(int priority) {
        configureRule(rule -> {
            rule.setPriority(priority);
        });
        return (T) this;
    }

    default T pathVar(String key, Object value) {
        return var(key, value);
    }

    default T var(String key, Object value) {
        configureRule(rule -> {
            Map map = rule.getExtraVarMap();
            if (map == null) {
                map = new HashMap();
            }
            map.put(key, value);
            rule.setExtraVarMap(map);
        });
        return (T) this;
    }

    default T attribute(String attribute) {
        configureRule(rule -> {
            List attrList = rule.getAttributeList();
            attrList.add(attribute);
        });
        return (T) this;
    }

    default T id(String id) {
        configureRule(rule -> {
            this.var(UrlMappingRuleSet.ID_VAR_NAME, id);
        });
        return (T) this;
    }

    default T matcher(DispatcherRuleMatcher ruleMatcher) {
        configureRule(rule -> {
            rule.setRuleMatcher(ruleMatcher);
        });
        return (T) this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy