io.atlassian.util.adapter.javax.el.JavaXVariableMapperAdapter 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.el;
import io.atlassian.util.adapter.jakarta.el.JakartaValueExpressionAdapter;
import io.atlassian.util.adapter.jakarta.el.JakartaVariableMapperAdapter;
import javax.el.ValueExpression;
import javax.el.VariableMapper;
import static io.atlassian.util.adapter.util.WrapperUtil.applyIfNonNull;
import static java.util.Objects.requireNonNull;
public class JavaXVariableMapperAdapter extends VariableMapper {
private final jakarta.el.VariableMapper delegate;
public static VariableMapper from(jakarta.el.VariableMapper delegate) {
if (delegate instanceof JakartaVariableMapperAdapter castDelegate) {
return castDelegate.getDelegate();
}
return applyIfNonNull(delegate, JavaXVariableMapperAdapter::new);
}
public JavaXVariableMapperAdapter(jakarta.el.VariableMapper delegate) {
this.delegate = requireNonNull(delegate);
}
public jakarta.el.VariableMapper getDelegate() {
return delegate;
}
@Override
public ValueExpression resolveVariable(String s) {
return JavaXValueExpressionAdapter.from(delegate.resolveVariable(s));
}
@Override
public ValueExpression setVariable(String s, ValueExpression valueExpression) {
return JavaXValueExpressionAdapter.from(delegate.setVariable(s, JakartaValueExpressionAdapter.from(valueExpression)));
}
}