1 45 46 package org.jfree.util; 47 48 import java.io.ObjectStreamException ; 49 import java.io.Serializable ; 50 51 56 public final class SortOrder implements Serializable { 57 58 59 private static final long serialVersionUID = -2124469847758108312L; 60 61 62 public static final SortOrder ASCENDING 63 = new SortOrder("SortOrder.ASCENDING"); 64 65 66 public static final SortOrder DESCENDING 67 = new SortOrder("SortOrder.DESCENDING"); 68 69 70 private String name; 71 72 77 private SortOrder(final String name) { 78 this.name = name; 79 } 80 81 86 public String toString() { 87 return this.name; 88 } 89 90 98 public boolean equals(final Object obj) { 99 100 if (this == obj) { 101 return true; 102 } 103 if (!(obj instanceof SortOrder)) { 104 return false; 105 } 106 107 final SortOrder that = (SortOrder) obj; 108 if (!this.name.equals(that.toString())) { 109 return false; 110 } 111 112 return true; 113 } 114 115 120 public int hashCode() { 121 return this.name.hashCode(); 122 } 123 124 131 private Object readResolve() throws ObjectStreamException { 132 if (this.equals(SortOrder.ASCENDING)) { 133 return SortOrder.ASCENDING; 134 } 135 else if (this.equals(SortOrder.DESCENDING)) { 136 return SortOrder.DESCENDING; 137 } 138 return null; 139 } 140 } 141 | Popular Tags |