org.spincast.plugins.routing.RoutingResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-plugins-routing Show documentation
Show all versions of spincast-plugins-routing Show documentation
The default Spincast Routing plugin
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