comparison java/src/java/lang/Boolean.d @ 21:9b96950f2c3c

the 'java' tree compiles on both D1-Tango and D2-Phobos
author Frank Benoit <benoit@tionex.de>
date Thu, 19 Mar 2009 20:38:55 +0100
parents 6dd524f61e62
children
comparison
equal deleted inserted replaced
20:dccb717aa902 21:9b96950f2c3c
1 module java.lang.Boolean; 1 module java.lang.Boolean;
2 2
3 import java.lang.util; 3 import java.lang.util;
4 import java.lang.System; 4 import java.lang.System;
5 5
6 version(Tango){
7 static import tango.text.Ascii;
8 } else { // Phobos
9 static import std.string;
10 }
6 class Boolean : ValueWrapperT!(bool) { 11 class Boolean : ValueWrapperT!(bool) {
7 public static Boolean TRUE; 12 public static Boolean TRUE;
8 public static Boolean FALSE; 13 public static Boolean FALSE;
9 14
10 static this(){ 15 static this(){
14 public this( bool v ){ 19 public this( bool v ){
15 super(v); 20 super(v);
16 } 21 }
17 22
18 alias ValueWrapperT!(bool).opEquals opEquals; 23 alias ValueWrapperT!(bool).opEquals opEquals;
19 public int opEquals( int other ){ 24 public equals_t opEquals( int other ){
20 return value == ( other !is 0 ); 25 return value == ( other !is 0 );
21 } 26 }
22 public int opEquals( Object other ){ 27 public equals_t opEquals( Object other ){
23 if( auto o = cast(Boolean)other ){ 28 if( auto o = cast(Boolean)other ){
24 return value == o.value; 29 return value == o.value;
25 } 30 }
26 return false; 31 return false;
27 } 32 }
36 } 41 }
37 public static Boolean valueOf( bool b ){ 42 public static Boolean valueOf( bool b ){
38 return b ? TRUE : FALSE; 43 return b ? TRUE : FALSE;
39 } 44 }
40 public static bool getBoolean(String name){ 45 public static bool getBoolean(String name){
41 return tango.text.Ascii.icompare(System.getProperty(name, "false"), "true" ) is 0; 46 version(Tango){
47 return tango.text.Ascii.icompare(System.getProperty(name, "false"), "true" ) is 0;
48 } else { // Phobos
49 return std.string.icmp(System.getProperty(name, "false"), "true" ) is 0;
50 }
42 } 51 }
43 } 52 }
44 53
45 alias Boolean ValueWrapperBool; 54 alias Boolean ValueWrapperBool;