org.spincast.plugins.routing.SpincastRoute 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.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;
import org.spincast.core.exchange.IRequestContext;
import org.spincast.core.routing.HttpMethod;
import org.spincast.core.routing.IHandler;
import org.spincast.core.routing.IRoute;
import org.spincast.core.routing.RoutingType;
import org.spincast.shaded.org.apache.commons.lang3.StringUtils;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
public class SpincastRoute> implements IRoute {
private final String id;
private final String path;
private final Set httpMethods;
private final Set acceptedContentTypes;
private final Set routingTypes;
private final List> beforeFilters;
private final IHandler mainHandler;
private final List> afterFilters;
private final List positions;
/**
* Constructor
*/
@AssistedInject
public SpincastRoute(@Assisted("id") @Nullable String id,
@Assisted Set httpMethods,
@Assisted("path") String path,
@Assisted Set routingTypes,
@Assisted("before") @Nullable List> beforeFilters,
@Assisted("main") IHandler mainHandler,
@Assisted("after") @Nullable List> afterFilters,
@Assisted Set positions,
@Assisted @Nullable Set acceptedContentTypes) {
this.id = id;
this.positions = new ArrayList(positions);
Collections.sort(this.positions);
this.httpMethods = httpMethods;
this.path = path;
this.routingTypes = routingTypes;
if(beforeFilters == null) {
beforeFilters = new ArrayList>();
}
this.beforeFilters = beforeFilters;
this.mainHandler = mainHandler;
if(afterFilters == null) {
afterFilters = new ArrayList>();
}
this.afterFilters = afterFilters;
if(acceptedContentTypes == null) {
acceptedContentTypes = new HashSet<>();
}
this.acceptedContentTypes = new HashSet();
for(String acceptedContentType : acceptedContentTypes) {
if(acceptedContentType != null) {
this.acceptedContentTypes.add(acceptedContentType.toLowerCase());
}
}
}
@Override
public Set getHttpMethods() {
return this.httpMethods;
}
@Override
public Set getAcceptedContentTypes() {
return this.acceptedContentTypes;
}
@Override
public String getId() {
return this.id;
}
@Override
public String getPath() {
return this.path;
}
@Override
public Set getRoutingTypes() {
return this.routingTypes;
}
@Override
public List> getBeforeFilters() {
return this.beforeFilters;
}
@Override
public IHandler getMainHandler() {
return this.mainHandler;
}
@Override
public List> getAfterFilters() {
return this.afterFilters;
}
@Override
public List getPositions() {
return this.positions;
}
@Override
public String toString() {
return "[" + StringUtils.join(getPositions(), ",") + "] " + getPath();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy