Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package org.litesoft.aokeyhole.persist;

public class DoneableBuilder
{
    protected final String mID;
    protected boolean mDone = false;
    private DoneableBuilder mCurrentChild;

    protected DoneableBuilder( String pID )
    {
        mID = pID;
    }

    protected final void LLdone()
    {
        checkCanDone();
        mCurrentChild = null;
        mDone = true;
    }

    protected final void checkCanDone()
    {
        if ( mDone )
        {
            throw new IllegalStateException( mID + " already 'done()'!" );
        }
        if ( mCurrentChild != null )
        {
            mCurrentChild.assertDone();
        }
    }

    protected final void assertDone()
    {
        if ( !mDone )
        {
            throw new IllegalStateException( mID + " NOT 'done()'!" );
        }
    }

    protected final <T extends DoneableBuilder> T child( T pChild )
    {
        mCurrentChild = pChild;
        return pChild;
    }

    protected final void checkCanAddProperty( String pWhy )
    {
        checkCanDone();
        if ( pWhy != null )
        {
            throw new IllegalStateException( "Properties may NOT be added to " + mID + " because " + pWhy + "!" );
        }
    }

    protected static final String ATTRIBUTES_ALREADY_ADDED = "Attribute already added";

    protected static final String SUB_SYSTEM = "SubSystemBuilder";
    private static final String OBJECT = "ObjectBuilder";
    private static final String ATTRIBUTE = "AttributeBuilder";

    protected static String objectID( String pName )
    {
        return OBJECT + "( " + pName + " )";
    }

    protected static String attributeID( String pObjectName, String pName )
    {
        return ATTRIBUTE + "( " + pObjectName + "." + pName + " )";
    }
}

Commits for litesoft/trunk/Java/KeyHole/src/org/litesoft/aokeyhole/persist/DoneableBuilder.java

Diff revisions: vs.
Revision Author Commited Message
830 GeorgeS picture GeorgeS Fri 31 Aug, 2012 18:10:19 +0000