StemmerModelDescriptor.java

1
/*******************************************************************************
2
 * Copyright (C) 2026, Leo Galambos
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 *    this list of conditions and the following disclaimer.
10
 *
11
 * 2. Redistributions in binary form must reproduce the above copyright notice,
12
 *    this list of conditions and the following disclaimer in the documentation
13
 *    and/or other materials provided with the distribution.
14
 *
15
 * 3. Neither the name of the copyright holder nor the names of its contributors
16
 *    may be used to endorse or promote products derived from this software
17
 *    without specific prior written permission.
18
 *
19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
 * POSSIBILITY OF SUCH DAMAGE.
30
 ******************************************************************************/
31
package org.egothor.stemmer;
32
33
import java.net.URL;
34
import java.util.Objects;
35
36
/**
37
 * Immutable validated metadata for one independently versioned Radixor model.
38
 *
39
 * <p>The descriptor identifies a GZip-compressed Radixor textual dictionary. It
40
 * does not contain a precompiled trie. Instances are created during deterministic
41
 * registry discovery and retain the descriptor URL used in diagnostics.</p>
42
 */
43
@SuppressWarnings({ "PMD.DataClass", "PMD.ExcessiveParameterList", "PMD.CommentDefaultAccessModifier" })
44
public final class StemmerModelDescriptor implements Comparable<StemmerModelDescriptor> {
45
    private final String id;
46
    private final String version;
47
    private final StemmerPatchTrieLoader.Language language;
48
    private final String displayName;
49
    private final String resource;
50
    private final boolean defaultModel;
51
    private final String format;
52
    private final int formatVersion;
53
    private final String sha256;
54
    private final URL source;
55
    private final ClassLoader classLoader;
56
57
    /** Creates a validated immutable descriptor. */
58
    StemmerModelDescriptor(final String id, final String version, final StemmerPatchTrieLoader.Language language,
59
            final String displayName, final String resource, final boolean defaultModel, final String format,
60
            final int formatVersion, final String sha256, final URL source, final ClassLoader classLoader) {
61
        this.id = Objects.requireNonNull(id, "id");
62
        this.version = Objects.requireNonNull(version, "version");
63
        this.language = Objects.requireNonNull(language, "language");
64
        this.displayName = Objects.requireNonNull(displayName, "displayName");
65
        this.resource = Objects.requireNonNull(resource, "resource");
66
        this.defaultModel = defaultModel;
67
        this.format = Objects.requireNonNull(format, "format");
68
        this.formatVersion = formatVersion;
69
        this.sha256 = Objects.requireNonNull(sha256, "sha256");
70
        this.source = Objects.requireNonNull(source, "source");
71
        this.classLoader = Objects.requireNonNull(classLoader, "classLoader");
72
    }
73
74
    /** Returns the stable model identifier used for explicit deterministic selection. */
75 1 1. id : replaced return value with "" for org/egothor/stemmer/StemmerModelDescriptor::id → KILLED
    public String id() { return this.id; }
76
    /** Returns the independently managed model artifact version. */
77 1 1. version : replaced return value with "" for org/egothor/stemmer/StemmerModelDescriptor::version → KILLED
    public String version() { return this.version; }
78
    /** Returns the represented language. */
79 1 1. language : replaced return value with null for org/egothor/stemmer/StemmerModelDescriptor::language → KILLED
    public StemmerPatchTrieLoader.Language language() { return this.language; }
80
    /** Returns the human-readable model name. */
81 1 1. displayName : replaced return value with "" for org/egothor/stemmer/StemmerModelDescriptor::displayName → NO_COVERAGE
    public String displayName() { return this.displayName; }
82
    /** Returns the namespaced classpath dictionary resource. */
83 1 1. resource : replaced return value with "" for org/egothor/stemmer/StemmerModelDescriptor::resource → KILLED
    public String resource() { return this.resource; }
84
    /**
85
     * Returns whether model metadata declares this model as a default candidate.
86
     * Language-oriented runtime resolution uses
87
     * {@link StemmerPatchTrieLoader.Language#defaultModelId()} as its authoritative
88
     * mapping.
89
     */
90 2 1. isDefaultModel : replaced boolean return with false for org/egothor/stemmer/StemmerModelDescriptor::isDefaultModel → NO_COVERAGE
2. isDefaultModel : replaced boolean return with true for org/egothor/stemmer/StemmerModelDescriptor::isDefaultModel → NO_COVERAGE
    public boolean isDefaultModel() { return this.defaultModel; }
91
    /** Returns the dictionary format identifier. */
92 1 1. format : replaced return value with "" for org/egothor/stemmer/StemmerModelDescriptor::format → KILLED
    public String format() { return this.format; }
93
    /** Returns the dictionary format version. */
94 1 1. formatVersion : replaced int return with 0 for org/egothor/stemmer/StemmerModelDescriptor::formatVersion → NO_COVERAGE
    public int formatVersion() { return this.formatVersion; }
95
    /** Returns the lowercase SHA-256 digest of the compressed runtime resource bytes. */
96 1 1. sha256 : replaced return value with "" for org/egothor/stemmer/StemmerModelDescriptor::sha256 → KILLED
    public String sha256() { return this.sha256; }
97
    /** Returns the descriptor source URL used for diagnostics. */
98 1 1. source : replaced return value with null for org/egothor/stemmer/StemmerModelDescriptor::source → NO_COVERAGE
    public URL source() { return this.source; }
99
    /** Returns the discovering class loader. */
100 1 1. classLoader : replaced return value with null for org/egothor/stemmer/StemmerModelDescriptor::classLoader → KILLED
    ClassLoader classLoader() { return this.classLoader; }
101
102
    /** Compares descriptors by stable model identifier. */
103
    @Override
104 1 1. compareTo : replaced int return with 0 for org/egothor/stemmer/StemmerModelDescriptor::compareTo → SURVIVED
    public int compareTo(final StemmerModelDescriptor other) { return this.id.compareTo(other.id); }
105
106
    /** Returns a concise descriptor representation. */
107
    @Override
108 1 1. toString : replaced return value with "" for org/egothor/stemmer/StemmerModelDescriptor::toString → NO_COVERAGE
    public String toString() { return this.id + "@" + this.version + " (" + this.source + ")"; }
109
}

Mutations

75

1.1
Location : id
Killed by : org.egothor.stemmer.StemmerModelDocumentationExamplesTest.[engine:junit-jupiter]/[class:org.egothor.stemmer.StemmerModelDocumentationExamplesTest]
replaced return value with "" for org/egothor/stemmer/StemmerModelDescriptor::id → KILLED

77

1.1
Location : version
Killed by : org.egothor.stemmer.StemmerModelDocumentationExamplesTest.[engine:junit-jupiter]/[class:org.egothor.stemmer.StemmerModelDocumentationExamplesTest]/[method:selectsExplicitPolimorfModel()]
replaced return value with "" for org/egothor/stemmer/StemmerModelDescriptor::version → KILLED

79

1.1
Location : language
Killed by : org.egothor.stemmer.StemmerModelDocumentationExamplesTest.[engine:junit-jupiter]/[class:org.egothor.stemmer.StemmerModelDocumentationExamplesTest]/[method:selectsExplicitPolimorfModel()]
replaced return value with null for org/egothor/stemmer/StemmerModelDescriptor::language → KILLED

81

1.1
Location : displayName
Killed by : none
replaced return value with "" for org/egothor/stemmer/StemmerModelDescriptor::displayName → NO_COVERAGE

83

1.1
Location : resource
Killed by : org.egothor.stemmer.StemmerModelDocumentationExamplesTest.[engine:junit-jupiter]/[class:org.egothor.stemmer.StemmerModelDocumentationExamplesTest]/[method:selectsExplicitPolimorfModel()]
replaced return value with "" for org/egothor/stemmer/StemmerModelDescriptor::resource → KILLED

90

1.1
Location : isDefaultModel
Killed by : none
replaced boolean return with false for org/egothor/stemmer/StemmerModelDescriptor::isDefaultModel → NO_COVERAGE

2.2
Location : isDefaultModel
Killed by : none
replaced boolean return with true for org/egothor/stemmer/StemmerModelDescriptor::isDefaultModel → NO_COVERAGE

92

1.1
Location : format
Killed by : org.egothor.stemmer.StemmerModelDocumentationExamplesTest.[engine:junit-jupiter]/[class:org.egothor.stemmer.StemmerModelDocumentationExamplesTest]/[method:discoversAndFiltersModels()]
replaced return value with "" for org/egothor/stemmer/StemmerModelDescriptor::format → KILLED

94

1.1
Location : formatVersion
Killed by : none
replaced int return with 0 for org/egothor/stemmer/StemmerModelDescriptor::formatVersion → NO_COVERAGE

96

1.1
Location : sha256
Killed by : org.egothor.stemmer.StemmerModelRegistryTest.[engine:junit-jupiter]/[class:org.egothor.stemmer.StemmerModelRegistryTest]/[method:loadsDefaultPolishModel()]
replaced return value with "" for org/egothor/stemmer/StemmerModelDescriptor::sha256 → KILLED

98

1.1
Location : source
Killed by : none
replaced return value with null for org/egothor/stemmer/StemmerModelDescriptor::source → NO_COVERAGE

100

1.1
Location : classLoader
Killed by : org.egothor.stemmer.StemmerModelRegistryTest.[engine:junit-jupiter]/[class:org.egothor.stemmer.StemmerModelRegistryTest]/[method:loadsDefaultPolishModel()]
replaced return value with null for org/egothor/stemmer/StemmerModelDescriptor::classLoader → KILLED

104

1.1
Location : compareTo
Killed by : none
replaced int return with 0 for org/egothor/stemmer/StemmerModelDescriptor::compareTo → SURVIVED
Covering tests

108

1.1
Location : toString
Killed by : none
replaced return value with "" for org/egothor/stemmer/StemmerModelDescriptor::toString → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.22.1