1 16 17 package org.springframework.validation; 18 19 import org.springframework.context.support.DefaultMessageSourceResolvable; 20 import org.springframework.util.Assert; 21 22 34 public class ObjectError extends DefaultMessageSourceResolvable { 35 36 private final String objectName; 37 38 39 47 public ObjectError(String objectName, String [] codes, Object [] arguments, String defaultMessage) { 48 super(codes, arguments, defaultMessage); 49 Assert.notNull(objectName, "Object name must not be null"); 50 this.objectName = objectName; 51 } 52 53 56 public String getObjectName() { 57 return objectName; 58 } 59 60 61 public String toString() { 62 return "Error in object '" + this.objectName + "': " + resolvableToString(); 63 } 64 65 public boolean equals(Object other) { 66 if (this == other) { 67 return true; 68 } 69 if (!(getClass().equals(other.getClass())) || !super.equals(other)) { 70 return false; 71 } 72 ObjectError otherError = (ObjectError) other; 73 return getObjectName().equals(otherError.getObjectName()); 74 } 75 76 public int hashCode() { 77 return super.hashCode() * 29 + getObjectName().hashCode(); 78 } 79 80 } 81 | Popular Tags |