io.atlassian.util.adapter.jakarta.servlet.JakartaServletRegistrationAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jakarta-adapters Show documentation
Show all versions of jakarta-adapters Show documentation
A collection of classes for adapting Servlet API 4.0 objects to Servlet API 5.0 and vice versa.
package io.atlassian.util.adapter.jakarta.servlet;
import io.atlassian.util.adapter.javax.servlet.JavaXServletRegistrationAdapter;
import jakarta.servlet.ServletRegistration;
import java.util.Collection;
import java.util.Set;
import static io.atlassian.util.adapter.util.WrapperUtil.applyIfNonNull;
import static java.util.Objects.requireNonNull;
public class JakartaServletRegistrationAdapter extends JakartaRegistrationAdapter implements ServletRegistration {
private final javax.servlet.ServletRegistration delegate;
public static ServletRegistration from(javax.servlet.ServletRegistration delegate) {
if (delegate instanceof javax.servlet.ServletRegistration.Dynamic castDelegate) {
return JakartaDynamicServletRegistrationAdapter.from(castDelegate);
}
if (delegate instanceof JavaXServletRegistrationAdapter castDelegate) {
return castDelegate.getDelegate();
}
return applyIfNonNull(delegate, JakartaServletRegistrationAdapter::new);
}
JakartaServletRegistrationAdapter(javax.servlet.ServletRegistration delegate) {
super(delegate);
this.delegate = requireNonNull(delegate);
}
@Override
public javax.servlet.ServletRegistration getDelegate() {
return delegate;
}
@Override
public Set addMapping(String... urlPatterns) {
return delegate.addMapping(urlPatterns);
}
@Override
public Collection getMappings() {
return delegate.getMappings();
}
@Override
public String getRunAsRole() {
return delegate.getRunAsRole();
}
}