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
72
73
74
75
76
77
package org.litesoft.language.model;

import org.litesoft.core.annotations.*;
import org.litesoft.core.typeutils.*;

public class MasterValidatedEntry extends Key
{
    public enum State
    {
        Unchecked, NoProblem, Empty, InvalidKey, SourceChanged
    }

    public MasterValidatedEntry( @NotEmpty String pKey, @NotEmpty String pUnvalidatedValue )
    {
        super( pKey );
        unvalidatedValue = Strings.assertNotNullNotEmpty( "UnvalidatedValue", pUnvalidatedValue );
    }

    public MasterValidatedEntry( @NotNull MasterUnvalidatedEntry pUnvalidatedEntry )
    {
        this( pUnvalidatedEntry.getKey(), pUnvalidatedEntry.getValue() );
    }

    public @NotNull String getUnvalidatedValue()
    {
        return unvalidatedValue;
    }

    public @NullableNotEmpty String getValidatedValue()
    {
        return validatedValue;
    }

    public void setValidatedValue( @NotEmpty String pValidatedValue )
    {
        validatedValue = Strings.assertNotNullNotEmpty( "ValidatedValue", pValidatedValue );
    }

    public @NotNull State getState()
    {
        return mState;
    }

    public State check( @Nullable MasterUnvalidatedEntry pUnvalidatedEntry )
    {
        if ( (pUnvalidatedEntry == null) || !this.getKey().equals( pUnvalidatedEntry.getKey() ) )
        {
            return mState = State.InvalidKey;
        }
        if (!this.getUnvalidatedValue().equals( pUnvalidatedEntry.getValue() )) {
            return mState = State.SourceChanged;
        }
        return mState = (null == getValidatedValue()) ? State.Empty : State.NoProblem;
    }

    public State update( @NotNull MasterUnvalidatedEntry pUnvalidatedEntry )
    {
        if ( (pUnvalidatedEntry == null) || !this.getKey().equals( pUnvalidatedEntry.getKey() ) )
        {
            return mState = State.InvalidKey;
        }
        if (!this.getUnvalidatedValue().equals( pUnvalidatedEntry.getValue() )) {
            return mState = State.SourceChanged;
        }
        return mState = (null == getValidatedValue()) ? State.Empty : State.NoProblem;
    }

    private String unvalidatedValue;
    private String validatedValue;

    private transient State mState = State.Unchecked;

    @Deprecated /** for Serialization */
    protected MasterValidatedEntry()
    {
    }
}

Commits for litesoft/trunk/DeviceDesktopTest/src/org/litesoft/language/model/MasterValidatedEntry.java

Diff revisions: vs.
Revision Author Commited Message
936 GeorgeS picture GeorgeS Sun 01 Jun, 2014 20:19:38 +0000

Language Support