All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.atlassian.util.adapter.jakarta.servlet.JakartaRegistrationAdapter Maven / Gradle / Ivy

Go to download

A collection of classes for adapting Servlet API 4.0 objects to Servlet API 5.0 and vice versa.

There is a newer version: 0.1.0
Show newest version
package io.atlassian.util.adapter.jakarta.servlet;

import io.atlassian.util.adapter.Adapted;
import io.atlassian.util.adapter.javax.servlet.JavaXRegistrationAdapter;
import jakarta.servlet.Registration;

import java.util.Map;
import java.util.Set;

import static io.atlassian.util.adapter.util.WrapperUtil.applyIfNonNull;
import static java.util.Objects.requireNonNull;

public class JakartaRegistrationAdapter implements Registration, Adapted {

    private final javax.servlet.Registration delegate;

    public static Registration from(javax.servlet.Registration delegate) {
        if (delegate instanceof javax.servlet.ServletRegistration castDelegate) {
            return JakartaServletRegistrationAdapter.from(castDelegate);
        }
        if (delegate instanceof javax.servlet.FilterRegistration castDelegate) {
            return JakartaFilterRegistrationAdapter.from(castDelegate);
        }
        if (delegate instanceof JavaXRegistrationAdapter castDelegate) {
            return castDelegate.getDelegate();
        }
        return applyIfNonNull(delegate, JakartaRegistrationAdapter::new);
    }

    protected JakartaRegistrationAdapter(javax.servlet.Registration delegate) {
        this.delegate = requireNonNull(delegate);
    }

    @Override
    public javax.servlet.Registration getDelegate() {
        return delegate;
    }

    @Override
    public String getName() {
        return delegate.getName();
    }

    @Override
    public String getClassName() {
        return delegate.getClassName();
    }

    @Override
    public boolean setInitParameter(String name, String value) {
        return delegate.setInitParameter(name, value);
    }

    @Override
    public String getInitParameter(String name) {
        return delegate.getInitParameter(name);
    }

    @Override
    public Set setInitParameters(Map initParameters) {
        return delegate.setInitParameters(initParameters);
    }

    @Override
    public Map getInitParameters() {
        return delegate.getInitParameters();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy