1 12 package org.eclipse.core.databinding.validation; 13 14 import org.eclipse.core.databinding.util.Policy; 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.core.runtime.Status; 17 18 24 public class ValidationStatus extends Status { 25 26 34 private ValidationStatus(int severity, String message, Throwable exception) { 35 super(severity, Policy.JFACE_DATABINDING, IStatus.OK, message, exception); 36 } 37 38 44 private ValidationStatus(int severity, String message) { 45 super(severity, Policy.JFACE_DATABINDING,IStatus.OK, message, null); 46 } 47 48 54 public static IStatus error(String message) { 55 return new ValidationStatus(IStatus.ERROR, message); 56 } 57 58 64 public static IStatus cancel(String message) { 65 return new ValidationStatus(IStatus.CANCEL, message); 66 } 67 68 76 public static IStatus error(String message, Throwable exception) { 77 return new ValidationStatus(IStatus.ERROR, message, exception); 78 } 79 80 86 public static IStatus warning(String message) { 87 return new ValidationStatus(IStatus.WARNING, message); 88 } 89 90 96 public static IStatus info(String message) { 97 return new ValidationStatus(IStatus.INFO, message); 98 } 99 100 105 public static IStatus ok() { 106 return Status.OK_STATUS; 107 } 108 109 114 public int hashCode() { 115 final int prime = 31; 116 int result = 1; 117 118 String message = getMessage(); 119 int severity = getSeverity(); 120 Throwable throwable = getException(); 121 122 result = prime * result + ((message == null) ? 0 : message.hashCode()); 123 result = prime * result + severity; 124 result = prime * result 125 + ((throwable == null) ? 0 : throwable.hashCode()); 126 return result; 127 } 128 129 134 public boolean equals(Object obj) { 135 if (this == obj) 136 return true; 137 if (obj == null) 138 return false; 139 if (getClass() != obj.getClass()) 140 return false; 141 final ValidationStatus other = (ValidationStatus) obj; 142 143 if (getSeverity() != other.getSeverity()) 144 return false; 145 if (getMessage() == null) { 146 if (other.getMessage() != null) 147 return false; 148 } else if (!getMessage().equals(other.getMessage())) 149 return false; 150 if (getException() == null) { 151 if (other.getException() != null) 152 return false; 153 } else if (!getException().equals(other.getException())) 154 return false; 155 return true; 156 } 157 } 158 | Popular Tags |