001 package edu.rice.cs.cunit.instrumentors.threadCheck;
002
003 import edu.rice.cs.cunit.instrumentors.util.IScannerStrategy;
004
005 /**
006 * Storage class for bad predicate annotation warnings.
007 */
008 public class BadPredicateAnnotationWarning extends RuntimeException
009 implements IScannerStrategy.IScanResult, Comparable<BadPredicateAnnotationWarning> {
010 /**
011 * Description of what was bad.
012 */
013 public final String desc;
014
015 /**
016 * Create a new bad predicate annotation warning.
017 * @param desc description of what was bad
018 */
019 public BadPredicateAnnotationWarning(String desc) {
020 this.desc = desc;
021 }
022
023 /**
024 * Return true if this object is equal to the other object.
025 * @param o other object
026 * @return true if equal
027 */
028 public boolean equals(Object o) {
029 if (this == o) {
030 return true;
031 }
032 if (o == null || getClass() != o.getClass()) {
033 return false;
034 }
035
036 BadPredicateAnnotationWarning that = (BadPredicateAnnotationWarning)o;
037
038 if (desc != null ? !desc.equals(that.desc) : that.desc != null) {
039 return false;
040 }
041
042 return true;
043 }
044
045 /**
046 * Return a hash code for this object.
047 * @return hash code
048 */
049 public int hashCode() {
050 return (desc != null ? desc.hashCode() : 0);
051 }
052
053 /**
054 * Compares this object with the specified object for order.
055 * @param o the Object to be compared.
056 *
057 * @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than
058 * the specified object.
059 *
060 * @throws ClassCastException if the specified object's type prevents it from being compared to this Object.
061 */
062 public int compareTo(BadPredicateAnnotationWarning o) {
063 return desc.compareTo(o.desc);
064 }
065
066 /**
067 * Returns a string representation of the object.
068 * @return a string representation of the object
069 */
070 public String toString() {
071 return desc;
072 }
073
074 /**
075 * Return the name of the property that was scanned for.
076 * @return property name
077 */
078 public String getPropertyName() {
079 return "ThreadChecker Bad Predicate Annotation Warning";
080 }
081 }