1 11 package org.eclipse.ltk.core.refactoring; 12 13 import org.eclipse.core.runtime.IProgressMonitor; 14 import org.eclipse.core.runtime.PlatformObject; 15 16 import org.eclipse.ltk.core.refactoring.history.IRefactoringHistoryService; 17 import org.eclipse.ltk.core.refactoring.history.RefactoringHistory; 18 19 import org.eclipse.ltk.internal.core.refactoring.history.RefactoringHistoryService; 20 21 55 public abstract class RefactoringDescriptorProxy extends PlatformObject implements Comparable { 56 57 60 public int compareTo(final Object object) { 61 if (object instanceof RefactoringDescriptorProxy) { 62 final RefactoringDescriptorProxy proxy= (RefactoringDescriptorProxy) object; 63 final long delta= getTimeStamp() - proxy.getTimeStamp(); 64 if (delta > 0) 65 return 1; 66 else if (delta < 0) 67 return -1; 68 return 0; 69 } 70 return 0; 71 } 72 73 76 public final boolean equals(final Object object) { 77 if (object instanceof RefactoringDescriptorProxy) { 78 final RefactoringDescriptorProxy proxy= (RefactoringDescriptorProxy) object; 79 return getTimeStamp() == proxy.getTimeStamp() && getDescription().equals(proxy.getDescription()); 80 } 81 return false; 82 } 83 84 89 public abstract String getDescription(); 90 91 96 public abstract String getProject(); 97 98 104 public abstract long getTimeStamp(); 105 106 109 public final int hashCode() { 110 int code= getDescription().hashCode(); 111 final long stamp= getTimeStamp(); 112 if (stamp >= 0) 113 code+= (17 * stamp); 114 return code; 115 } 116 117 129 public RefactoringDescriptor requestDescriptor(final IProgressMonitor monitor) { 130 return RefactoringHistoryService.getInstance().requestDescriptor(this, monitor); 131 } 132 } 133 | Popular Tags |