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

org.spincast.plugins.routing.RoutingResult Maven / Gradle / Ivy

The newest version!
package org.spincast.plugins.routing;

import java.util.ArrayList;
import java.util.List;

import org.spincast.core.exchange.IRequestContext;
import org.spincast.core.routing.IRouteHandlerMatch;
import org.spincast.core.routing.IRoutingResult;

public class RoutingResult> implements IRoutingResult {

    private final List> routeHandlerMatches;

    public RoutingResult(List> routeHandlerMatches) {
        if(routeHandlerMatches == null) {
            routeHandlerMatches = new ArrayList>();
        }
        this.routeHandlerMatches = routeHandlerMatches;
    }

    @Override
    public List> getRouteHandlerMatches() {
        return this.routeHandlerMatches;
    }

    @Override
    public String toString() {

        List> routeHandlerMatches = getRouteHandlerMatches();
        if(routeHandlerMatches.size() == 0) {
            return "No match";
        }

        for(IRouteHandlerMatch routeHandlerMatch : routeHandlerMatches) {
            if(routeHandlerMatch.getPosition() == 0) {
                return "Route matched : " + routeHandlerMatch.getHandler();
            }
        }
        return "Filters only";
    }

    @Override
    public IRouteHandlerMatch getMainRouteHandlerMatch() {

        List> routeHandlerMatches = getRouteHandlerMatches();
        if(routeHandlerMatches != null) {
            for(IRouteHandlerMatch routeHandlerMatch : routeHandlerMatches) {
                if(routeHandlerMatch != null &&
                   routeHandlerMatch.getPosition() == 0) {
                    return routeHandlerMatch;
                }
            }
        }
        return null;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy