1 42 43 package org.jfree.util; 44 45 import java.io.ObjectStreamException ; 46 import java.io.Serializable ; 47 48 53 public final class UnitType implements Serializable { 54 55 56 private static final long serialVersionUID = 6531925392288519884L; 57 58 59 public static final UnitType ABSOLUTE = new UnitType("UnitType.ABSOLUTE"); 60 61 62 public static final UnitType RELATIVE = new UnitType("UnitType.RELATIVE"); 63 64 65 private String name; 66 67 72 private UnitType(final String name) { 73 this.name = name; 74 } 75 76 81 public String toString() { 82 return this.name; 83 } 84 85 93 public boolean equals(final Object obj) { 94 if (obj == this) { 95 return true; 96 } 97 if (!(obj instanceof UnitType)) { 98 return false; 99 } 100 final UnitType that = (UnitType) obj; 101 if (!this.name.equals(that.name)) { 102 return false; 103 } 104 return true; 105 } 106 107 112 public int hashCode() { 113 return this.name.hashCode(); 114 } 115 116 123 private Object readResolve() throws ObjectStreamException { 124 if (this.equals(UnitType.ABSOLUTE)) { 125 return UnitType.ABSOLUTE; 126 } 127 else if (this.equals(UnitType.RELATIVE)) { 128 return UnitType.RELATIVE; 129 } 130 return null; 131 } 132 133 } 134 | Popular Tags |