|
@@ -1,76 +1,76 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.bo.attributes; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.commonfoundation.typeutils.*; |
5 |
|
- |
import org.litesoft.core.simpletypes.nonpublic.*; |
6 |
|
- |
|
7 |
|
- |
import java.util.*; |
8 |
|
- |
|
9 |
|
- |
public class BooleanDisplayOptions implements PropertyOfAMD { |
10 |
|
- |
public static BooleanDisplayOptions of( String pTrueFalseText ) { |
11 |
|
- |
if ( null == (pTrueFalseText = Strings.noEmpty( pTrueFalseText )) ) { |
12 |
|
- |
return null; |
13 |
|
- |
} |
14 |
|
- |
int zAt = pTrueFalseText.indexOf( '/' ); |
15 |
|
- |
if ( zAt != -1 ) { |
16 |
|
- |
if ( (zAt != 0) && (zAt != (pTrueFalseText.length() - 1)) && (-1 == pTrueFalseText.indexOf( '/', zAt + 1 )) ) { |
17 |
|
- |
return getInstance( pTrueFalseText, zAt ); |
18 |
|
- |
} |
19 |
|
- |
} |
20 |
|
- |
throw new IllegalArgumentException( "True &/ False text missing (seperated by a '/')" ); |
21 |
|
- |
} |
22 |
|
- |
|
23 |
|
- |
public static BooleanDisplayOptions get( AttributeMetaData pAMD ) { |
24 |
|
- |
return (BooleanDisplayOptions) pAMD.getProperties().get( MAP_KEY ); |
25 |
|
- |
} |
26 |
|
- |
|
27 |
|
- |
private static synchronized BooleanDisplayOptions getInstance( String pTrueFalseText, int pSepAt ) { |
28 |
|
- |
BooleanDisplayOptions zInstance = sInstances.get( pTrueFalseText ); |
29 |
|
- |
if ( zInstance == null ) { |
30 |
|
- |
sInstances.put( pTrueFalseText, zInstance = new BooleanDisplayOptions( pTrueFalseText, pSepAt ) ); |
31 |
|
- |
} |
32 |
|
- |
return zInstance; |
33 |
|
- |
} |
34 |
|
- |
|
35 |
|
- |
private static HashMap<String, BooleanDisplayOptions> sInstances = new HashMap<String, BooleanDisplayOptions>(); |
36 |
|
- |
|
37 |
|
- |
private static final String MAP_KEY = "BooleanDisplayOptions"; |
38 |
|
- |
|
39 |
|
- |
private BooleanDisplayOptions( String pTrueFalseText, int pSepAt ) { |
40 |
|
- |
mTrueText = pTrueFalseText.substring( 0, pSepAt ); |
41 |
|
- |
mFalseText = pTrueFalseText.substring( pSepAt + 1 ); |
42 |
|
- |
} |
43 |
|
- |
|
44 |
|
- |
private String mTrueText, mFalseText; |
45 |
|
- |
|
46 |
|
- |
public String getTrueText() { |
47 |
|
- |
return mTrueText; |
48 |
|
- |
} |
49 |
|
- |
|
50 |
|
- |
public String getFalseText() { |
51 |
|
- |
return mFalseText; |
52 |
|
- |
} |
53 |
|
- |
|
54 |
|
- |
@Override |
55 |
|
- |
public String toString() { |
56 |
|
- |
return MAP_KEY + ".of( \"" + mTrueText + '/' + mFalseText + "\" )"; |
57 |
|
- |
} |
58 |
|
- |
|
59 |
|
- |
public String getMapKey() { |
60 |
|
- |
return MAP_KEY; |
61 |
|
- |
} |
62 |
|
- |
|
63 |
|
- |
@Override |
64 |
|
- |
public boolean equals( Object them ) { |
65 |
|
- |
return (this == them) || ((them != null) && (this.getClass() == them.getClass()) && LLequals( (BooleanDisplayOptions) them )); |
66 |
|
- |
} |
67 |
|
- |
|
68 |
|
- |
private boolean LLequals( BooleanDisplayOptions them ) { |
69 |
|
- |
return (this.mTrueText.equals( them.mTrueText )) && (this.mFalseText.equals( them.mFalseText )); |
70 |
|
- |
} |
71 |
|
- |
|
72 |
|
- |
@Override |
73 |
|
- |
public int hashCode() { |
74 |
|
- |
return EqualSupport.hashCodeEm( mTrueText.hashCode(), mFalseText.hashCode() ); |
75 |
|
- |
} |
76 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.bo.attributes; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.commonfoundation.base.*; |
|
5 |
+ |
import org.litesoft.core.simpletypes.nonpublic.*; |
|
6 |
+ |
|
|
7 |
+ |
import java.util.*; |
|
8 |
+ |
|
|
9 |
+ |
public class BooleanDisplayOptions implements PropertyOfAMD { |
|
10 |
+ |
public static BooleanDisplayOptions of( String pTrueFalseText ) { |
|
11 |
+ |
if ( null == (pTrueFalseText = ConstrainTo.significantOrNull( pTrueFalseText )) ) { |
|
12 |
+ |
return null; |
|
13 |
+ |
} |
|
14 |
+ |
int zAt = pTrueFalseText.indexOf( '/' ); |
|
15 |
+ |
if ( zAt != -1 ) { |
|
16 |
+ |
if ( (zAt != 0) && (zAt != (pTrueFalseText.length() - 1)) && (-1 == pTrueFalseText.indexOf( '/', zAt + 1 )) ) { |
|
17 |
+ |
return getInstance( pTrueFalseText, zAt ); |
|
18 |
+ |
} |
|
19 |
+ |
} |
|
20 |
+ |
throw new IllegalArgumentException( "True &/ False text missing (seperated by a '/')" ); |
|
21 |
+ |
} |
|
22 |
+ |
|
|
23 |
+ |
public static BooleanDisplayOptions get( AttributeMetaData pAMD ) { |
|
24 |
+ |
return (BooleanDisplayOptions) pAMD.getProperties().get( MAP_KEY ); |
|
25 |
+ |
} |
|
26 |
+ |
|
|
27 |
+ |
private static synchronized BooleanDisplayOptions getInstance( String pTrueFalseText, int pSepAt ) { |
|
28 |
+ |
BooleanDisplayOptions zInstance = sInstances.get( pTrueFalseText ); |
|
29 |
+ |
if ( zInstance == null ) { |
|
30 |
+ |
sInstances.put( pTrueFalseText, zInstance = new BooleanDisplayOptions( pTrueFalseText, pSepAt ) ); |
|
31 |
+ |
} |
|
32 |
+ |
return zInstance; |
|
33 |
+ |
} |
|
34 |
+ |
|
|
35 |
+ |
private static HashMap<String, BooleanDisplayOptions> sInstances = new HashMap<String, BooleanDisplayOptions>(); |
|
36 |
+ |
|
|
37 |
+ |
private static final String MAP_KEY = "BooleanDisplayOptions"; |
|
38 |
+ |
|
|
39 |
+ |
private BooleanDisplayOptions( String pTrueFalseText, int pSepAt ) { |
|
40 |
+ |
mTrueText = pTrueFalseText.substring( 0, pSepAt ); |
|
41 |
+ |
mFalseText = pTrueFalseText.substring( pSepAt + 1 ); |
|
42 |
+ |
} |
|
43 |
+ |
|
|
44 |
+ |
private String mTrueText, mFalseText; |
|
45 |
+ |
|
|
46 |
+ |
public String getTrueText() { |
|
47 |
+ |
return mTrueText; |
|
48 |
+ |
} |
|
49 |
+ |
|
|
50 |
+ |
public String getFalseText() { |
|
51 |
+ |
return mFalseText; |
|
52 |
+ |
} |
|
53 |
+ |
|
|
54 |
+ |
@Override |
|
55 |
+ |
public String toString() { |
|
56 |
+ |
return MAP_KEY + ".of( \"" + mTrueText + '/' + mFalseText + "\" )"; |
|
57 |
+ |
} |
|
58 |
+ |
|
|
59 |
+ |
public String getMapKey() { |
|
60 |
+ |
return MAP_KEY; |
|
61 |
+ |
} |
|
62 |
+ |
|
|
63 |
+ |
@Override |
|
64 |
+ |
public boolean equals( Object them ) { |
|
65 |
+ |
return (this == them) || ((them != null) && (this.getClass() == them.getClass()) && LLequals( (BooleanDisplayOptions) them )); |
|
66 |
+ |
} |
|
67 |
+ |
|
|
68 |
+ |
private boolean LLequals( BooleanDisplayOptions them ) { |
|
69 |
+ |
return (this.mTrueText.equals( them.mTrueText )) && (this.mFalseText.equals( them.mFalseText )); |
|
70 |
+ |
} |
|
71 |
+ |
|
|
72 |
+ |
@Override |
|
73 |
+ |
public int hashCode() { |
|
74 |
+ |
return EqualSupport.hashCodeEm( mTrueText.hashCode(), mFalseText.hashCode() ); |
|
75 |
+ |
} |
|
76 |
+ |
} |