1 16 17 package org.springframework.validation; 18 19 import org.springframework.util.Assert; 20 21 33 public class FieldError extends ObjectError { 34 35 private final String field; 36 37 private final Object rejectedValue; 38 39 private final boolean bindingFailure; 40 41 42 53 public FieldError( 54 String objectName, String field, Object rejectedValue, boolean bindingFailure, 55 String [] codes, Object [] arguments, String defaultMessage) { 56 57 super(objectName, codes, arguments, defaultMessage); 58 Assert.notNull(field, "Field must not be null"); 59 this.field = field; 60 this.rejectedValue = rejectedValue; 61 this.bindingFailure = bindingFailure; 62 } 63 64 65 68 public String getField() { 69 return field; 70 } 71 72 75 public Object getRejectedValue() { 76 return rejectedValue; 77 } 78 79 83 public boolean isBindingFailure() { 84 return bindingFailure; 85 } 86 87 88 public String toString() { 89 return "Field error in object '" + getObjectName() + "' on field '" + this.field + 90 "': rejected value [" + this.rejectedValue + "]; " + resolvableToString(); 91 } 92 93 public boolean equals(Object other) { 94 if (this == other) { 95 return true; 96 } 97 if (!super.equals(other)) { 98 return false; 99 } 100 FieldError otherError = (FieldError) other; 101 return getField().equals(otherError.getField()); 102 } 103 104 public int hashCode() { 105 return super.hashCode() * 29 + getField().hashCode(); 106 } 107 108 } 109
| Popular Tags
|