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

jreleaser / jreleaser / #477

04 Apr 2025 05:53PM UTC coverage: 35.124% (-5.1%) from 40.183%
#477

push

github

aalmiray
fix(deploy): Add missing Forgejo messages

Related to #1842

18210 of 51845 relevant lines covered (35.12%)

0.35 hits per line

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

64.52
/api/jreleaser-model-api/src/main/java/org/jreleaser/mustache/TemplateContext.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 *
4
 * Copyright 2020-2025 The JReleaser authors.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     https://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
package org.jreleaser.mustache;
19

20
import java.util.LinkedHashMap;
21
import java.util.Map;
22
import java.util.Set;
23

24
/**
25
 * @author Andres Almiray
26
 * @since 1.5.0
27
 */
28
public final class TemplateContext {
29
    private final Map<String, Object> properties = new LinkedHashMap<>();
1✔
30

31
    public static TemplateContext empty() {
32
        return new TemplateContext();
×
33
    }
34

35
    public static TemplateContext from(Map<String, Object> props) {
36
        if (props != null) {
×
37
            return new TemplateContext(props);
×
38
        }
39
        return new TemplateContext();
×
40
    }
41

42
    public TemplateContext() {
1✔
43
    }
1✔
44

45
    public TemplateContext(Map<String, Object> props) {
×
46
        this.properties.putAll(props);
×
47
    }
×
48

49
    public TemplateContext(TemplateContext other) {
1✔
50
        setAll(other);
1✔
51
    }
1✔
52

53
    public boolean isEmpty() {
54
        return properties.isEmpty();
×
55
    }
56

57
    public Set<String> keys() {
58
        return properties.keySet();
×
59
    }
60

61
    public Set<Map.Entry<String, Object>> entries() {
62
        return properties.entrySet();
1✔
63
    }
64

65
    public boolean contains(String key) {
66
        return properties.containsKey(key);
×
67
    }
68

69
    public <V> V get(String key) {
70
        return (V) properties.get(key);
1✔
71
    }
72

73
    public TemplateContext setAll(TemplateContext other) {
74
        if (null != other) properties.putAll(other.properties);
1✔
75
        return this;
1✔
76
    }
77

78
    public <V> TemplateContext setAll(Map<String, V> props) {
79
        if (null == props || props.isEmpty()) return this;
1✔
80
        props.forEach(this::set);
1✔
81
        return this;
1✔
82
    }
83

84
    public <V> V set(String key, V value) {
85
        V previousValue = (V) properties.get(key);
1✔
86
        if (null != value) properties.put(key, value);
1✔
87
        return previousValue;
1✔
88
    }
89

90
    public <V> V set(String key, V value, V defaultValue) {
91
        V previousValue = (V) properties.get(key);
1✔
92
        if (null != value && null != defaultValue) properties.put(key, value);
1✔
93
        return previousValue;
1✔
94
    }
95

96
    public <V> V remove(String key) {
97
        return (V) properties.remove(key);
×
98
    }
99

100
    public Map<String, Object> asMap() {
101
        return properties;
1✔
102
    }
103
}
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

© 2026 Coveralls, Inc