1 5 package com.jofti.model; 6 7 15 public class ComparableBoolean implements Comparable 16 { 17 private Boolean value =Boolean.FALSE; 18 19 public ComparableBoolean(String value){ 20 this.value = Boolean.valueOf(value); 21 } 22 public ComparableBoolean(Boolean value){ 23 this.value = value; 24 } 25 26 public ComparableBoolean(boolean value){ 27 this.value = Boolean.valueOf(value); 28 } 29 30 33 public int compareTo(Object arg0) 34 { 35 if (arg0 instanceof ComparableBoolean){ 36 ComparableBoolean temp = (ComparableBoolean)arg0; 37 if (value.equals(Boolean.FALSE)){ 38 if (temp.value.equals(Boolean.FALSE)){ 39 return 0; 40 }else{ 41 return -1; 42 } 43 }else{ 44 if (temp.value.equals(Boolean.TRUE)){ 45 return 0; 46 }else{ 47 return 1; 48 } 49 } 50 }else{ 51 return -1; 52 } 53 54 } 55 56 public int hashCode(){ 57 return value.hashCode(); 58 } 59 60 public boolean equals(Object obj){ 61 return value.equals(obj); 62 } 63 64 public String toString(){ 65 return value.toString(); 66 } 67 } 68 | Popular Tags |