MutableNode.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.trie;
32
33
import java.util.LinkedHashMap;
34
import java.util.Map;
35
36
/**
37
 * Mutable build-time node.
38
 *
39
 * <p>
40
 * The maps exposed by the accessors are the internal mutable backing state of
41
 * the node. They are returned directly for efficiency and are intended only for
42
 * closely related trie-building infrastructure.
43
 *
44
 * @param <V> value type
45
 */
46
public final class MutableNode<V> {
47
48
    /**
49
     * Child nodes indexed by transition character.
50
     */
51
    private final Map<Character, MutableNode<V>> children;
52
53
    /**
54
     * Local terminal value counts stored exactly at this node.
55
     */
56
    private final Map<V, Integer> valueCounts;
57
58
    /**
59
     * Creates an empty node.
60
     */
61
    public MutableNode() {
62
        this.children = new LinkedHashMap<>();
63
        this.valueCounts = new LinkedHashMap<>();
64
    }
65
66
    /**
67
     * Returns the internal child-node map indexed by transition character.
68
     *
69
     * <p>
70
     * The returned map is the internal mutable backing state of this node and is
71
     * exposed only for efficient cooperation with trie-building infrastructure.
72
     *
73
     * @return internal child-node map
74
     */
75
    public Map<Character, MutableNode<V>> children() {
76 1 1. children : replaced return value with Collections.emptyMap for org/egothor/stemmer/trie/MutableNode::children → KILLED
        return this.children;
77
    }
78
79
    /**
80
     * Returns the internal local terminal value-count map.
81
     *
82
     * <p>
83
     * The returned map is the internal mutable backing state of this node and is
84
     * exposed only for efficient cooperation with trie-building infrastructure.
85
     *
86
     * @return internal local value-count map
87
     */
88
    public Map<V, Integer> valueCounts() {
89 1 1. valueCounts : replaced return value with Collections.emptyMap for org/egothor/stemmer/trie/MutableNode::valueCounts → KILLED
        return this.valueCounts;
90
    }
91
}

Mutations

76

1.1
Location : children
Killed by : org.egothor.stemmer.trie.MutableNodeTest.[engine:junit-jupiter]/[class:org.egothor.stemmer.trie.MutableNodeTest]/[method:shouldExposeMutableBackingChildrenMap()]
replaced return value with Collections.emptyMap for org/egothor/stemmer/trie/MutableNode::children → KILLED

89

1.1
Location : valueCounts
Killed by : org.egothor.stemmer.trie.MutableNodeTest.[engine:junit-jupiter]/[class:org.egothor.stemmer.trie.MutableNodeTest]/[method:shouldExposeMutableBackingValueCountsMap()]
replaced return value with Collections.emptyMap for org/egothor/stemmer/trie/MutableNode::valueCounts → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.1