1 32 33 package com.jeantessier.diff; 34 35 import org.apache.log4j.*; 36 37 43 public abstract class RemovableDifferences implements Differences, Comparable { 44 private String name; 45 46 private String oldDeclaration = null; 47 private String newDeclaration = null; 48 49 protected RemovableDifferences(String name) { 50 this.name = name; 51 } 52 53 public String getName() { 54 return name; 55 } 56 57 public String getOldDeclaration() { 58 return oldDeclaration; 59 } 60 61 public void setOldDeclaration(String oldDeclaration) { 62 this.oldDeclaration = oldDeclaration; 63 } 64 65 public String getNewDeclaration() { 66 return newDeclaration; 67 } 68 69 public void setNewDeclaration(String newDeclaration) { 70 this.newDeclaration = newDeclaration; 71 } 72 73 public boolean isRemoved() { 74 boolean result = (oldDeclaration != null) && (newDeclaration == null); 75 76 Logger.getLogger(getClass()).debug(getName() + " IsRemoved(): " + result); 77 78 return result; 79 } 80 81 public boolean isModified() { 82 boolean result = (oldDeclaration != null) && (newDeclaration != null) && !oldDeclaration.equals(newDeclaration); 83 84 Logger.getLogger(getClass()).debug(getName() + " IsModified(): " + result); 85 86 return result; 87 } 88 89 public boolean isNew() { 90 boolean result = (oldDeclaration == null) && (newDeclaration != null); 91 92 Logger.getLogger(getClass()).debug(getName() + " IsNew(): " + result); 93 94 return result; 95 } 96 97 public boolean isEmpty() { 98 return 99 !isNew() && 100 !isModified() && 101 !isRemoved(); 102 } 103 104 public String toString() { 105 return getName(); 106 } 107 108 public int compareTo(Object other) { 109 int result = 0; 110 111 if (other instanceof RemovableDifferences) { 112 result = getName().compareTo(((RemovableDifferences) other).getName()); 113 } else { 114 throw new ClassCastException ("Unable to compare RemovableDifferences to " + other.getClass().getName()); 115 } 116 117 return result; 118 } 119 } 120 | Popular Tags |