4 * License : The MIT License
\r
5 * Copyright(c) 2009 olyutorskii
\r
8 package jp.sourceforge.jindolf.json;
\r
13 public final class JsBoolean
\r
14 extends AbstractJsValue
\r
15 implements Comparable<JsBoolean> {
\r
18 public static final JsBoolean TRUE = new JsBoolean();
\r
20 public static final JsBoolean FALSE = new JsBoolean();
\r
23 * boolean値から真偽Valueを返す。
\r
24 * @param bool boolean値
\r
25 * @return TRUEかFALSE
\r
27 public static JsBoolean valueOf(boolean bool){
\r
28 if(bool) return TRUE;
\r
36 private JsBoolean(){
\r
45 public boolean booleanValue(){
\r
46 if(this == TRUE) return true;
\r
54 public boolean isTrue(){
\r
55 if(this == TRUE) return true;
\r
63 public boolean isFalse(){
\r
64 if(this == FALSE) return true;
\r
70 * @return {@inheritDoc}
\r
73 public int hashCode(){
\r
74 if(this.isTrue()) return Boolean.TRUE.hashCode();
\r
75 return Boolean.FALSE.hashCode();
\r
80 * @param obj {@inheritDoc}
\r
81 * @return {@inheritDoc}
\r
84 public boolean equals(Object obj){
\r
85 if(obj == null) return false;
\r
86 if(this == obj) return true;
\r
88 if( ! (obj instanceof JsBoolean) ) return false;
\r
95 * @param value {@inheritDoc}
\r
96 * @return {@inheritDoc}
\r
98 public int compareTo(JsBoolean value){
\r
99 if(value == null) throw new NullPointerException();
\r
100 if(this == value) return 0;
\r
102 if (this.isTrue() && value.isFalse()) return -1;
\r
103 else if(this.isFalse() && value.isTrue() ) return +1;
\r
110 * @return {@inheritDoc}
\r
113 public String toString(){
\r
114 if(this.isTrue()) return "true";
\r