• 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

82.22
/core/jreleaser-model-impl/src/main/java/org/jreleaser/model/internal/platform/Platform.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.model.internal.platform;
19

20
import com.fasterxml.jackson.annotation.JsonIgnore;
21
import org.jreleaser.model.internal.common.AbstractModelObject;
22
import org.jreleaser.model.internal.common.Domain;
23

24
import java.util.LinkedHashMap;
25
import java.util.Map;
26

27
import static java.util.Collections.unmodifiableMap;
28
import static org.jreleaser.util.StringUtils.isBlank;
29

30
/**
31
 * @author Andres Almiray
32
 * @since 0.10.0
33
 */
34
public final class Platform extends AbstractModelObject<Platform> implements Domain {
1✔
35
    private static final long serialVersionUID = -5939953296773672903L;
36

37
    private final Map<String, String> replacements = new LinkedHashMap<>();
1✔
38

39
    @JsonIgnore
1✔
40
    private final org.jreleaser.model.api.platform.Platform immutable = new org.jreleaser.model.api.platform.Platform() {
1✔
41
        private static final long serialVersionUID = 7959953437571066163L;
42

43
        @Override
44
        public Map<String, String> getReplacements() {
45
            return unmodifiableMap(replacements);
×
46
        }
47

48
        @Override
49
        public String applyReplacements(String platform) {
50
            return Platform.this.applyReplacements(platform);
×
51
        }
52

53
        @Override
54
        public Map<String, Object> asMap(boolean full) {
55
            return unmodifiableMap(Platform.this.asMap(full));
×
56
        }
57
    };
58

59
    public org.jreleaser.model.api.platform.Platform asImmutable() {
60
        return immutable;
×
61
    }
62

63
    @Override
64
    public void merge(Platform source) {
65
        setReplacements(merge(this.replacements, source.replacements));
1✔
66
    }
1✔
67

68
    public boolean isSet() {
69
        return !replacements.isEmpty();
×
70
    }
71

72
    public Map<String, String> getReplacements() {
73
        return replacements;
×
74
    }
75

76
    public void setReplacements(Map<String, String> replacements) {
77
        this.replacements.putAll(replacements);
1✔
78
    }
1✔
79

80
    @Override
81
    public Map<String, Object> asMap(boolean full) {
82
        Map<String, Object> map = new LinkedHashMap<>();
1✔
83
        map.put("replacements", replacements);
1✔
84
        return map;
1✔
85
    }
86

87
    public String applyReplacements(String platform) {
88
        if (isBlank(platform)) return platform;
1✔
89

90
        for (Map.Entry<String, String> e : replacements.entrySet()) {
1✔
91
            if (e.getKey().equals(platform)) {
1✔
92
                return e.getValue();
1✔
93
            }
94
        }
1✔
95

96
        String[] parts = platform.split("-");
1✔
97
        for (int i = 0; i < parts.length; i++) {
1✔
98
            for (Map.Entry<String, String> e : replacements.entrySet()) {
1✔
99
                if (e.getKey().equals(parts[i])) {
1✔
100
                    parts[i] = e.getValue();
1✔
101
                }
102
            }
1✔
103
        }
104

105
        return String.join("-", parts);
1✔
106
    }
107

108
    public Platform mergeValues(Platform other) {
109
        Platform merged = new Platform();
1✔
110

111
        Map<String, String> full = new LinkedHashMap<>();
1✔
112
        Map<String, String> partial = new LinkedHashMap<>();
1✔
113

114
        for (Map.Entry<String, String> e : replacements.entrySet()) {
1✔
115
            if (e.getKey().contains("-")) {
1✔
116
                full.put(e.getKey(), e.getValue());
×
117
            } else {
118
                partial.put(e.getKey(), e.getValue());
1✔
119
            }
120
        }
1✔
121

122
        for (Map.Entry<String, String> e : other.replacements.entrySet()) {
1✔
123
            if (e.getKey().contains("-")) {
1✔
124
                full.put(e.getKey(), e.getValue());
×
125
            } else {
126
                partial.put(e.getKey(), e.getValue());
1✔
127
            }
128
        }
1✔
129

130
        merged.replacements.putAll(full);
1✔
131
        merged.replacements.putAll(partial);
1✔
132

133
        return merged;
1✔
134
    }
135
}
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