private boolean isMatch(Map.Entry<String, ?> entry) { if (entry.getValue() == null) { return false; } if (!getModelKeys().isEmpty() && !getModelKeys().contains(entry.getKey())) { return false; } ResolvableType type = ResolvableType.forInstance(entry.getValue()); return getMessageWriter().canWrite(type, null); }
/** * Whether the given model attribute key-value pair is eligible for encoding. * <p>The default implementation checks against the configured * {@link #setModelKeys model keys} and whether the Encoder supports the * value type. */ protected boolean isEligibleAttribute(String attributeName, Object attributeValue) { ResolvableType type = ResolvableType.forClass(attributeValue.getClass()); if (getModelKeys().isEmpty()) { return getMessageWriter().canWrite(type, null); } if (getModelKeys().contains(attributeName)) { if (getMessageWriter().canWrite(type, null)) { return true; } throw new IllegalStateException( "Model object [" + attributeValue + "] retrieved via key " + "[" + attributeName + "] is not supported by " + getMessageWriter()); } return false; }