List of usage examples for org.springframework.web.servlet.support BindStatus getActualValue
@Nullable
public Object getActualValue()
From source file:org.hdiv.web.servlet.tags.form.SelectedValueComparatorHDIV.java
/** * Returns <code>true</code> if the supplied candidate value is equal to the value bound to * the supplied {@link BindStatus}. Equality in this case differs from standard Java equality and * is described in more detail <a href="#equality-contract">here</a>. *//*from ww w. ja v a2s . co m*/ public static boolean isSelected(BindStatus bindStatus, Object candidateValue) { if (bindStatus == null) { return (candidateValue == null); } // Check obvious equality matches with the candidate first, // both with the rendered value and with the original value. Object boundValue = bindStatus.getValue(); if (ObjectUtils.nullSafeEquals(boundValue, candidateValue)) { return true; } Object actualValue = bindStatus.getActualValue(); if (actualValue != null && actualValue != boundValue && ObjectUtils.nullSafeEquals(actualValue, candidateValue)) { return true; } if (actualValue != null) { boundValue = actualValue; } else if (boundValue == null) { return false; } // Non-null value but no obvious equality with the candidate value: // go into more exhaustive comparisons. boolean selected = false; if (boundValue.getClass().isArray()) { selected = collectionCompare(CollectionUtils.arrayToList(boundValue), candidateValue, bindStatus); } else if (boundValue instanceof Collection) { selected = collectionCompare((Collection) boundValue, candidateValue, bindStatus); } else if (boundValue instanceof Map) { selected = mapCompare((Map) boundValue, candidateValue, bindStatus); } if (!selected) { selected = exhaustiveCompare(boundValue, candidateValue, bindStatus.getEditor(), null); } return selected; }