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

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

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

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import org.spincast.core.exchange.IRequestContext;
import org.spincast.core.routing.IHandler;
import org.spincast.core.routing.IRoute;
import org.spincast.core.routing.IRouteHandlerMatch;

import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;

public class RouteHandlerMatch> implements IRouteHandlerMatch {

    private final IRoute sourceRoute;
    private final IHandler routeHandler;
    private final Map params;

    private final int position;

    @AssistedInject
    public RouteHandlerMatch(@Assisted IRoute sourceRoute,
                             @Assisted IHandler routeHandler,
                             @Assisted Map params,
                             @Assisted int position) {

        Objects.requireNonNull(sourceRoute, "sourceRoute can't be NULL");
        this.sourceRoute = sourceRoute;

        Objects.requireNonNull(routeHandler, "routeHandler can't be NULL");
        this.routeHandler = routeHandler;

        Objects.requireNonNull(position, "position can't be NULL");
        this.position = position;

        if(params == null) {
            params = new HashMap();
        }
        this.params = params;
    }

    @Override
    public IRoute getSourceRoute() {
        return this.sourceRoute;
    }

    @Override
    public IHandler getHandler() {
        return this.routeHandler;
    }

    @Override
    public Map getParameters() {
        return this.params;
    }

    @Override
    public int getPosition() {
        return this.position;
    }

    @Override
    public String toString() {
        return "Match for route: " + getSourceRoute();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy