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
27 private JsBoolean(){
\r
34 * boolean値から真偽Valueを返す。
\r
35 * @param bool boolean値
\r
36 * @return TRUEかFALSE
\r
38 public static JsBoolean valueOf(boolean bool){
\r
39 if(bool) return TRUE;
\r
47 public boolean booleanValue(){
\r
48 if(this == TRUE) return true;
\r
56 public boolean isTrue(){
\r
57 if(this == TRUE) return true;
\r
65 public boolean isFalse(){
\r
66 if(this == FALSE) return true;
\r
72 * @return {@inheritDoc}
\r
75 public int hashCode(){
\r
76 if(this.isTrue()) return Boolean.TRUE.hashCode();
\r
77 return Boolean.FALSE.hashCode();
\r
82 * @param obj {@inheritDoc}
\r
83 * @return {@inheritDoc}
\r
86 public boolean equals(Object obj){
\r
87 if(obj == null) return false;
\r
88 if(this == obj) return true;
\r
90 if( ! (obj instanceof JsBoolean) ) return false;
\r
97 * @param value {@inheritDoc}
\r
98 * @return {@inheritDoc}
\r
101 public int compareTo(JsBoolean value){
\r
102 if(value == null) throw new NullPointerException();
\r
103 if(this == value) return 0;
\r
105 if (this.isTrue() && value.isFalse()) return -1;
\r
106 else if(this.isFalse() && value.isTrue() ) return +1;
\r
113 * @return {@inheritDoc}
\r
116 public String toString(){
\r
117 if(this.isTrue()) return "true";
\r