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

stasha / flex / 17

29 Apr 2025 11:38PM UTC coverage: 67.722% (-6.4%) from 74.123%
17

push

circleci

stasha
Added bunch of changes and various experiments

206 of 343 branches covered (60.06%)

Branch coverage included in aggregate %.

143 of 219 new or added lines in 12 files covered. (65.3%)

4 existing lines in 2 files now uncovered.

436 of 605 relevant lines covered (72.07%)

0.72 hits per line

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

0.0
/src/main/java/com/stasha/info/flex/FlexProperty.java
1
package com.stasha.info.flex;
2

3
import com.stasha.info.flex.parsers.FlexParsedTemplate;
4
import com.stasha.info.flex.parsers.FlexStringTemplateParser;
5
import java.util.ArrayList;
6
import java.util.Arrays;
7
import java.util.LinkedHashMap;
8
import java.util.List;
9
import java.util.Map;
10
import java.util.regex.Matcher;
11
import java.util.regex.Pattern;
12

13
/**
14
 *
15
 * @author stasha
16
 */
17
public class FlexProperty {
18

NEW
19
    public static final Pattern GENDER_PATTERN = Pattern.compile("^([^\\[]+)?\\s*\\[([^\\|]+)?\\|([^\\|]+)?\\|([^\\]]+)?]$");
×
20

NEW
21
    private FlexStringTemplateParser parser = new FlexStringTemplateParser();
×
22

23
    private String key;
24
    private String name;
25
    private String index;
26
    private String value;
NEW
27
    private Map<Object, String> options = new LinkedHashMap<>();
×
NEW
28
    private List<FlexProperty> properties = new ArrayList<>();
×
29
    private String[] formatters;
NEW
30
    private boolean isPartOfCollection = false;
×
31

NEW
32
    public FlexProperty() {
×
NEW
33
    }
×
34

NEW
35
    public FlexProperty(String key, String value) {
×
36
//        System.out.println(key + " : " + value);
NEW
37
        this.key = key;
×
NEW
38
        this.value = value;
×
39

NEW
40
        if (key != null && key.endsWith("]")) {
×
NEW
41
            String option = key.substring(0, key.lastIndexOf("["));
×
NEW
42
            String optionIndex = key.substring(key.lastIndexOf("[") + 1, key.lastIndexOf("]"));
×
43

NEW
44
            this.name = option;
×
NEW
45
            this.index = optionIndex;
×
NEW
46
            this.value = value;
×
47
        }
48

NEW
49
        if (value != null) {
×
NEW
50
            if (value.endsWith("]")) {
×
NEW
51
                Matcher m = GENDER_PATTERN.matcher(value);
×
NEW
52
                if (m.find()) {
×
NEW
53
                    String gn = m.group(1);
×
NEW
54
                    this.options.put("m", gn + m.group(2));
×
NEW
55
                    this.options.put("f", gn + m.group(3));
×
NEW
56
                    this.options.put("u", gn + m.group(4));
×
NEW
57
                    this.isPartOfCollection = true;
×
58
                }
NEW
59
            } else if (value.contains("{")) {
×
NEW
60
                FlexParsedTemplate t = parser.parse(value);
×
NEW
61
                if (t != null) {
×
62
//                    templates.forEach(t -> {
NEW
63
                        FlexProperty prop = new FlexProperty();
×
NEW
64
                        prop.key = this.key;
×
NEW
65
                        prop.value = t.getStrToReplace();
×
NEW
66
                        prop.index = t.getValue();
×
NEW
67
                        if (t.getOptions() != null && t.getOptions().getData() != null) {
×
NEW
68
                            prop.options.putAll(t.getOptions().getData());
×
69
                        }
NEW
70
                        prop.formatters = t.getFormats();
×
NEW
71
                        this.properties.add(prop);
×
72
//                    });
73
                }
74
//                if (template != null && template.getOptions().hasOptions()) {
75
//                    this.values = new HashMap<>();
76
//                    this.values.putAll(template.getOptions().getData());
77
//                }
78
            }
79
        }
80

NEW
81
    }
×
82

83
    public String getKey() {
NEW
84
        return key;
×
85
    }
86

87
    public String getName() {
NEW
88
        return name;
×
89
    }
90

91
    public String getIndex() {
NEW
92
        return index;
×
93
    }
94

95
    public String getValue() {
NEW
96
        return value;
×
97
    }
98

99
    public Map<Object, String> getOptions() {
NEW
100
        return options;
×
101
    }
102

103
    public List<FlexProperty> getProperties() {
NEW
104
        return properties;
×
105
    }
106

107
    public String[] getFormatters() {
NEW
108
        return formatters;
×
109
    }
110

111
    public boolean isPartOfCollection() {
NEW
112
        return this.isPartOfCollection;
×
113
    }
114

115
    public String getValue(String option) {
NEW
116
        if (this.options != null) {
×
NEW
117
            return this.options.getOrDefault(option, this.options.getOrDefault("other", value));
×
118
        }
NEW
119
        return value;
×
120
    }
121

122
    @Override
123
    public String toString() {
NEW
124
        return "FlexProperty{" + "key=" + key + ", name=" + name + ", index=" + index + ", value=" + value + ", options=" + options + ", properties=" + properties + ", formatters=" + Arrays.toString(formatters) + ", isPartOfCollection=" + isPartOfCollection + '}';
×
125
    }
126

127
}
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