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

io.atlassian.util.adapter.javax.el.JavaXImportHandlerAdapter 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.javax.el;

import io.atlassian.util.adapter.jakarta.el.JakartaImportHandlerAdapter;

import javax.el.ELException;
import javax.el.ImportHandler;

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

public class JavaXImportHandlerAdapter extends ImportHandler {

    private final jakarta.el.ImportHandler delegate;

    public static ImportHandler from(jakarta.el.ImportHandler delegate) {
        if (delegate instanceof JakartaImportHandlerAdapter castDelegate) {
            return castDelegate.getDelegate();
        }
        return applyIfNonNull(delegate, JavaXImportHandlerAdapter::new);
    }

    JavaXImportHandlerAdapter(jakarta.el.ImportHandler delegate) {
        this.delegate = requireNonNull(delegate);
    }

    public jakarta.el.ImportHandler getDelegate() {
        return delegate;
    }

    @Override
    public void importStatic(String name) throws ELException {
        delegate.importStatic(name);
    }

    @Override
    public void importClass(String name) throws ELException {
        delegate.importClass(name);
    }

    @Override
    public void importPackage(String packageName) {
        if (delegate == null) {
            return; // Ignore call from super constructor
        }
        delegate.importPackage(packageName);
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy