io.atlassian.util.adapter.javax.servlet.http.JavaXPartAdapter 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.javax.servlet.http;
import io.atlassian.util.adapter.jakarta.servlet.http.JakartaPartAdapter;
import javax.servlet.http.Part;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import static io.atlassian.util.adapter.util.WrapperUtil.applyIfNonNull;
import static java.util.Objects.requireNonNull;
public class JavaXPartAdapter implements Part {
private final jakarta.servlet.http.Part delegate;
public static Part from(jakarta.servlet.http.Part delegate) {
if (delegate instanceof JakartaPartAdapter castDelegate) {
return castDelegate.getDelegate();
}
return applyIfNonNull(delegate, JavaXPartAdapter::new);
}
JavaXPartAdapter(jakarta.servlet.http.Part delegate) {
this.delegate = requireNonNull(delegate);
}
public jakarta.servlet.http.Part getDelegate() {
return delegate;
}
@Override
public InputStream getInputStream() throws IOException {
return delegate.getInputStream();
}
@Override
public String getContentType() {
return delegate.getContentType();
}
@Override
public String getName() {
return delegate.getName();
}
@Override
public String getSubmittedFileName() {
return delegate.getSubmittedFileName();
}
@Override
public long getSize() {
return delegate.getSize();
}
@Override
public void write(String fileName) throws IOException {
delegate.write(fileName);
}
@Override
public void delete() throws IOException {
delegate.delete();
}
@Override
public String getHeader(String name) {
return delegate.getHeader(name);
}
@Override
public Collection getHeaders(String name) {
return delegate.getHeaders(name);
}
@Override
public Collection getHeaderNames() {
return delegate.getHeaderNames();
}
}