OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 80 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 80 Rev 149
Line 15... Line 15...
15
 
15
 
16
import org.openconcerto.utils.CompareUtils;
16
import org.openconcerto.utils.CompareUtils;
17
 
17
 
18
import java.beans.DefaultPersistenceDelegate;
18
import java.beans.DefaultPersistenceDelegate;
19
import java.beans.PersistenceDelegate;
19
import java.beans.PersistenceDelegate;
-
 
20
import java.util.Collection;
20
import java.util.Comparator;
21
import java.util.Comparator;
-
 
22
import java.util.LinkedHashSet;
-
 
23
import java.util.Set;
21
import java.util.regex.Pattern;
24
import java.util.regex.Pattern;
22
 
25
 
23
import net.jcip.annotations.Immutable;
26
import net.jcip.annotations.Immutable;
24
 
27
 
25
@Immutable
28
@Immutable
Line 36... Line 39...
36
            else
39
            else
37
                return -o1.getVersion().compareTo(o2.getVersion());
40
                return -o1.getVersion().compareTo(o2.getVersion());
38
        }
41
        }
39
    };
42
    };
40
 
43
 
-
 
44
    static public final Set<String> getIDs(final Set<ModuleReference> refs) {
-
 
45
        return getIDs(refs, new LinkedHashSet<String>(refs.size()));
-
 
46
    }
-
 
47
 
-
 
48
    static public final <C extends Collection<String>> C getIDs(final Collection<ModuleReference> refs, final C res) {
-
 
49
        for (final ModuleReference mref : refs) {
-
 
50
            res.add(mref.getID());
-
 
51
        }
-
 
52
        return res;
-
 
53
    }
-
 
54
 
41
    static String checkMatch(final Pattern p, final String s, final String name) {
55
    static String checkMatch(final Pattern p, final String s, final String name) {
42
        if (!p.matcher(s).matches())
56
        if (!p.matcher(s).matches())
43
            throw new IllegalArgumentException(name + " doesn't match " + p.pattern());
57
            throw new IllegalArgumentException(name + " doesn't match " + p.pattern());
44
        return s;
58
        return s;
45
    }
59
    }
Line 60... Line 74...
60
     */
74
     */
61
    public ModuleReference(String id, ModuleVersion version) {
75
    public ModuleReference(String id, ModuleVersion version) {
62
        if (id == null)
76
        if (id == null)
63
            throw new NullPointerException();
77
            throw new NullPointerException();
64
        this.id = checkMatch(idPatrn, id.trim(), "ID");
78
        this.id = checkMatch(idPatrn, id.trim(), "ID");
-
 
79
        if (version != null)
-
 
80
            version.checkValidity();
65
        this.version = version;
81
        this.version = version;
66
    }
82
    }
67
 
83
 
68
    public final String getID() {
84
    public final String getID() {
69
        return this.id;
85
        return this.id;