Subversion Repository Public Repository

litesoft

Diff Revisions 948 vs 950 for /trunk/GWT_Sandbox/FormEngine/src/com/temp/client/foundation/widget/input/fieldsupport/StateInputField.java

Diff revisions: vs.
  @@ -1,90 +1,90 @@
1 - package com.temp.client.foundation.widget.input.fieldsupport;
2 -
3 - /**
4 - * The State of an InputField is the combination of the following boolean states:
5 - * <p/>
6 - * Changed
7 - * Errored
8 - * Focused
9 - */
10 - public class StateInputField {
11 - public static final StateInputField BASE = new StateInputField( false, false, false );
12 -
13 - private boolean mChanged, mErrored, mFocused;
14 -
15 - private StateInputField( boolean pChanged, boolean pErrored, boolean pFocused ) {
16 - mChanged = pChanged;
17 - mErrored = pErrored;
18 - mFocused = pFocused;
19 - }
20 -
21 - public boolean isChanged() {
22 - return mChanged;
23 - }
24 -
25 - public boolean isErrored() {
26 - return mErrored;
27 - }
28 -
29 - public boolean isFocused() {
30 - return mFocused;
31 - }
32 -
33 - public StateInputField changed( boolean pChanged ) {
34 - return changeTo( pChanged, mErrored, mFocused );
35 - }
36 -
37 - public StateInputField errored( boolean pErrored ) {
38 - return changeTo( mChanged, pErrored, mFocused );
39 - }
40 -
41 - public StateInputField focused( boolean pFocused ) {
42 - return changeTo( mChanged, mErrored, pFocused );
43 - }
44 -
45 - private StateInputField changeTo( boolean pChanged, boolean pErrored, boolean pFocused ) {
46 - if ( (mChanged == pChanged) && (mErrored == pErrored) && (mFocused == pFocused) ) {
47 - return this;
48 - }
49 - return new StateInputField( pChanged, pErrored, pFocused );
50 - }
51 -
52 - @Override
53 - public boolean equals( Object o ) {
54 - return (this == o) || ((o instanceof StateInputField) && equals( (StateInputField) o ));
55 - }
56 -
57 - public boolean equals( StateInputField them ) {
58 - return (them != null) //
59 - && (this.mChanged == them.mChanged) //
60 - && (this.mErrored == them.mErrored) //
61 - && (this.mFocused == them.mFocused);
62 - }
63 -
64 - @Override
65 - public int hashCode() {
66 - int result = (mChanged ? 1 : 0);
67 - result = (result << 1) + (mErrored ? 1 : 0);
68 - result = (result << 1) + (mFocused ? 1 : 0);
69 - return result;
70 - }
71 -
72 - @Override
73 - public String toString() {
74 - StringBuilder sb = new StringBuilder();
75 - add( sb, "Changed", mChanged );
76 - add( sb, "Errored", mErrored );
77 - add( sb, "Focused", mFocused );
78 - return sb.toString();
79 - }
80 -
81 - public String toCSS() {
82 - return "IF_Box" + this;
83 - }
84 -
85 - private void add( StringBuilder sb, String what, boolean flag ) {
86 - if ( flag ) {
87 - sb.append( what );
88 - }
89 - }
90 - }
1 + package com.temp.client.foundation.widget.input.fieldsupport;
2 +
3 + /**
4 + * The State of an InputField is the combination of the following boolean states:
5 + * <p/>
6 + * Changed
7 + * Errored
8 + * Focused
9 + */
10 + public class StateInputField {
11 + public static final StateInputField BASE = new StateInputField( false, false, false );
12 +
13 + private boolean mChanged, mErrored, mFocused;
14 +
15 + private StateInputField( boolean pChanged, boolean pErrored, boolean pFocused ) {
16 + mChanged = pChanged;
17 + mErrored = pErrored;
18 + mFocused = pFocused;
19 + }
20 +
21 + public boolean isChanged() {
22 + return mChanged;
23 + }
24 +
25 + public boolean isErrored() {
26 + return mErrored;
27 + }
28 +
29 + public boolean isFocused() {
30 + return mFocused;
31 + }
32 +
33 + public StateInputField changed( boolean pChanged ) {
34 + return changeTo( pChanged, mErrored, mFocused );
35 + }
36 +
37 + public StateInputField errored( boolean pErrored ) {
38 + return changeTo( mChanged, pErrored, mFocused );
39 + }
40 +
41 + public StateInputField focused( boolean pFocused ) {
42 + return changeTo( mChanged, mErrored, pFocused );
43 + }
44 +
45 + private StateInputField changeTo( boolean pChanged, boolean pErrored, boolean pFocused ) {
46 + if ( (mChanged == pChanged) && (mErrored == pErrored) && (mFocused == pFocused) ) {
47 + return this;
48 + }
49 + return new StateInputField( pChanged, pErrored, pFocused );
50 + }
51 +
52 + @Override
53 + public boolean equals( Object o ) {
54 + return (this == o) || ((o instanceof StateInputField) && equals( (StateInputField) o ));
55 + }
56 +
57 + public boolean equals( StateInputField them ) {
58 + return (them != null) //
59 + && (this.mChanged == them.mChanged) //
60 + && (this.mErrored == them.mErrored) //
61 + && (this.mFocused == them.mFocused);
62 + }
63 +
64 + @Override
65 + public int hashCode() {
66 + int result = (mChanged ? 1 : 0);
67 + result = (result << 1) + (mErrored ? 1 : 0);
68 + result = (result << 1) + (mFocused ? 1 : 0);
69 + return result;
70 + }
71 +
72 + @Override
73 + public String toString() {
74 + StringBuilder sb = new StringBuilder();
75 + add( sb, "Changed", mChanged );
76 + add( sb, "Errored", mErrored );
77 + add( sb, "Focused", mFocused );
78 + return sb.toString();
79 + }
80 +
81 + public String toCSS() {
82 + return "IF_Box" + this;
83 + }
84 +
85 + private void add( StringBuilder sb, String what, boolean flag ) {
86 + if ( flag ) {
87 + sb.append( what );
88 + }
89 + }
90 + }