diff --git a/src/main/java/net/abhinavsarkar/spelhelper/ImplicitConstructorResolver.java b/src/main/java/net/abhinavsarkar/spelhelper/ImplicitConstructorResolver.java index 352bce6..63ec4eb 100644 --- a/src/main/java/net/abhinavsarkar/spelhelper/ImplicitConstructorResolver.java +++ b/src/main/java/net/abhinavsarkar/spelhelper/ImplicitConstructorResolver.java @@ -27,8 +27,7 @@ import org.springframework.expression.ConstructorResolver; import org.springframework.expression.EvaluationContext; import org.springframework.expression.spel.support.ReflectiveConstructorResolver; -final class ImplicitConstructorResolver implements - ConstructorResolver { +final class ImplicitConstructorResolver implements ConstructorResolver { private final ReflectiveConstructorResolver delegate = new ReflectiveConstructorResolver(); diff --git a/src/main/java/net/abhinavsarkar/spelhelper/ImplicitMethodResolver.java b/src/main/java/net/abhinavsarkar/spelhelper/ImplicitMethodResolver.java index 7614aef..acc9be9 100644 --- a/src/main/java/net/abhinavsarkar/spelhelper/ImplicitMethodResolver.java +++ b/src/main/java/net/abhinavsarkar/spelhelper/ImplicitMethodResolver.java @@ -39,20 +39,21 @@ final class ImplicitMethodResolver implements MethodResolver { private final ReflectiveMethodResolver delegate = new ReflectiveMethodResolver(); private static final MethodExecutor NULL_ME = new MethodExecutor() { + @Override public TypedValue execute(final EvaluationContext context, final Object target, final Object... arguments) throws AccessException { - return null; + throw new UnsupportedOperationException("This method should never be called"); } }; - private static final class ImplicitMethodExecutor implements - MethodExecutor { + private static final class ImplicitMethodExecutor implements MethodExecutor { private final MethodExecutor executor; public ImplicitMethodExecutor(final MethodExecutor executor) { this.executor = executor; } + @Override public TypedValue execute(final EvaluationContext context, final Object target, final Object... arguments) throws AccessException { Object[] modifiedArguments = new Object[arguments.length + 1]; @@ -66,7 +67,7 @@ final class ImplicitMethodResolver implements MethodResolver { public MethodExecutor resolve( final EvaluationContext context, final Object targetObject, final String name, final List argumentTypes) - throws AccessException { + throws AccessException { if (targetObject == null) { return null; } diff --git a/src/main/java/net/abhinavsarkar/spelhelper/ImplicitPropertyAccessor.java b/src/main/java/net/abhinavsarkar/spelhelper/ImplicitPropertyAccessor.java index 63c7111..75c510c 100644 --- a/src/main/java/net/abhinavsarkar/spelhelper/ImplicitPropertyAccessor.java +++ b/src/main/java/net/abhinavsarkar/spelhelper/ImplicitPropertyAccessor.java @@ -34,13 +34,22 @@ final class ImplicitPropertyAccessor extends ReadOnlyGenericPropertyAccessor { private static final ConcurrentHashMap CACHE = new ConcurrentHashMap(); + private static final MethodExecutor NULL_ME = new MethodExecutor() { + @Override + public TypedValue execute(final EvaluationContext context, final Object target, + final Object... arguments) throws AccessException { + throw new UnsupportedOperationException("This method should never be called"); + } + }; + + @Override public boolean canRead(final EvaluationContext context, final Object target, final String name) throws AccessException { Assert.notNull(target, "target is null"); String cacheKey = target.getClass().getName() + "." + name; if (CACHE.containsKey(cacheKey)) { - return CACHE.get(cacheKey) != null; + return CACHE.get(cacheKey) != NULL_ME; } for (MethodResolver mr : context.getMethodResolvers()) { @@ -52,10 +61,11 @@ final class ImplicitPropertyAccessor extends ReadOnlyGenericPropertyAccessor { } } - CACHE.putIfAbsent(cacheKey, null); + CACHE.putIfAbsent(cacheKey, NULL_ME); return false; } + @Override public TypedValue read(final EvaluationContext context, final Object target, final String name) throws AccessException { diff --git a/src/main/java/net/abhinavsarkar/spelhelper/ReadOnlyGenericPropertyAccessor.java b/src/main/java/net/abhinavsarkar/spelhelper/ReadOnlyGenericPropertyAccessor.java index 1931353..56701e3 100644 --- a/src/main/java/net/abhinavsarkar/spelhelper/ReadOnlyGenericPropertyAccessor.java +++ b/src/main/java/net/abhinavsarkar/spelhelper/ReadOnlyGenericPropertyAccessor.java @@ -23,19 +23,21 @@ import org.springframework.expression.AccessException; import org.springframework.expression.EvaluationContext; import org.springframework.expression.PropertyAccessor; -abstract class ReadOnlyGenericPropertyAccessor implements - PropertyAccessor { +abstract class ReadOnlyGenericPropertyAccessor implements PropertyAccessor { + @Override public final boolean canWrite(final EvaluationContext context, final Object target, final String name) throws AccessException { return false; } + @Override @SuppressWarnings("rawtypes") public final Class[] getSpecificTargetClasses() { return null; } + @Override public final void write(final EvaluationContext context, final Object target, final String name, final Object newValue) throws AccessException { throw new AccessException(MessageFormat.format(