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