• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LearnLib / automatalib / 13138848026

04 Feb 2025 02:53PM UTC coverage: 92.108% (+2.2%) from 89.877%
13138848026

push

github

mtf90
[maven-release-plugin] prepare release automatalib-0.12.0

16609 of 18032 relevant lines covered (92.11%)

1.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/commons/util/src/main/java/net/automatalib/common/util/mapping/MapMapping.java
1
/* Copyright (C) 2013-2025 TU Dortmund University
2
 * This file is part of AutomataLib <https://automatalib.net>.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package net.automatalib.common.util.mapping;
17

18
import java.util.HashMap;
19
import java.util.Map;
20

21
/**
22
 * Class that wraps a {@link Mapping} around a {@link Map}.
23
 *
24
 * @param <D>
25
 *         domain type.
26
 * @param <R>
27
 *         range type.
28
 */
29
public class MapMapping<D, R> implements MutableMapping<D, R> {
30

31
    private final Map<D, R> map;
32

33
    /**
34
     * Constructor.
35
     */
36
    public MapMapping() {
37
        this(new HashMap<>());
1✔
38
    }
1✔
39

40
    /**
41
     * Constructor.
42
     *
43
     * @param map
44
     *         the underlying {@link Map} object.
45
     */
46
    public MapMapping(Map<D, R> map) {
47
        this(map, false);
1✔
48
    }
1✔
49

50
    /**
51
     * Constructor.
52
     *
53
     * @param map
54
     *         the underlying {@link Map} object.
55
     * @param copy
56
     *         whether the given map should be copied or stored by reference.
57
     */
58
    public MapMapping(Map<D, R> map, boolean copy) {
1✔
59
        if (copy) {
1✔
60
            this.map = new HashMap<>(map);
×
61
        } else {
62
            this.map = map;
1✔
63
        }
64
    }
1✔
65

66
    @Override
67
    public R get(D elem) {
68
        return map.get(elem);
1✔
69
    }
70

71
    @Override
72
    public R put(D key, R value) {
73
        return map.put(key, value);
1✔
74
    }
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc