io.atlassian.util.adapter.jakarta.servlet.JakartaServletConfigAdapter 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.Adapted;
import io.atlassian.util.adapter.javax.servlet.JavaXServletConfigAdapter;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletContext;
import java.util.Enumeration;
import static io.atlassian.util.adapter.jakarta.JakartaAdapters.asJakarta;
import static io.atlassian.util.adapter.util.WrapperUtil.applyIfNonNull;
import static java.util.Objects.requireNonNull;
public class JakartaServletConfigAdapter implements ServletConfig, Adapted {
private final javax.servlet.ServletConfig delegate;
public static ServletConfig from(javax.servlet.ServletConfig delegate) {
if (delegate instanceof JavaXServletConfigAdapter castDelegate) {
return castDelegate.getDelegate();
}
return applyIfNonNull(delegate, JakartaServletConfigAdapter::new);
}
protected JakartaServletConfigAdapter(javax.servlet.ServletConfig delegate) {
this.delegate = requireNonNull(delegate);
}
@Override
public javax.servlet.ServletConfig getDelegate() {
return delegate;
}
@Override
public String getServletName() {
return delegate.getServletName();
}
@Override
public ServletContext getServletContext() {
return asJakarta(delegate.getServletContext());
}
@Override
public String getInitParameter(String s) {
return delegate.getInitParameter(s);
}
@Override
public Enumeration getInitParameterNames() {
return delegate.getInitParameterNames();
}
}