4 * License : The MIT License
5 * Copyright(c) 2009 olyutorskii
8 package jp.sourceforge.jindolf.json;
13 public final class JsBoolean
14 extends AbstractJsValue
15 implements Comparable<JsBoolean> {
18 public static final JsBoolean TRUE = new JsBoolean();
20 public static final JsBoolean FALSE = new JsBoolean();
34 * boolean値から真偽Valueを返す。
35 * @param bool boolean値
38 public static JsBoolean valueOf(boolean bool){
47 public boolean booleanValue(){
48 if(this == TRUE) return true;
56 public boolean isTrue(){
57 if(this == TRUE) return true;
65 public boolean isFalse(){
66 if(this == FALSE) return true;
72 * @return {@inheritDoc}
75 public int hashCode(){
76 if(this.isTrue()) return Boolean.TRUE.hashCode();
77 return Boolean.FALSE.hashCode();
82 * @param obj {@inheritDoc}
83 * @return {@inheritDoc}
86 public boolean equals(Object obj){
87 if(obj == null) return false;
88 if(this == obj) return true;
90 if( ! (obj instanceof JsBoolean) ) return false;
97 * @param value {@inheritDoc}
98 * @return {@inheritDoc}
101 public int compareTo(JsBoolean value){
102 if(value == null) throw new NullPointerException();
103 if(this == value) return 0;
105 if (this.isTrue() && value.isFalse()) return -1;
106 else if(this.isFalse() && value.isTrue() ) return +1;
113 * @return {@inheritDoc}
116 public String toString(){
117 if(this.isTrue()) return "true";