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

common-workflow-language / cwljava / #394

31 Oct 2025 04:10PM UTC coverage: 57.972% (-1.6%) from 59.538%
#394

push

github

mr-c
rename package to a namespace that we control

7575 of 12994 new or added lines in 261 files covered. (58.3%)

7752 of 13372 relevant lines covered (57.97%)

0.58 hits per line

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

84.44
/src/main/java/org/commonwl/cwlsdk/cwl1_2/utils/TypeDslLoader.java
1
package org.commonwl.cwlsdk.cwl1_2.utils;
2

3
import java.util.ArrayList;
4
import java.util.Arrays;
5
import java.util.HashMap;
6
import java.util.List;
7
import java.util.regex.Matcher;
8
import java.util.regex.Pattern;
9

10
public class TypeDslLoader<T> implements Loader<T> {
11
  private final Loader<T> innerLoader;
12
  private final Integer refScope;
13
  private static final Pattern TYPE_DSL_REGEX = Pattern.compile("^([^\\[?]+)(\\[\\])?(\\?)?$");
1✔
14

15
  public TypeDslLoader(final Loader<T> innerLoader, final Integer refScope) {
1✔
16
    this.innerLoader = innerLoader;
1✔
17
    this.refScope = refScope;
1✔
18
  }
1✔
19

20
  private Object resolve(
21
      final String doc_, final String baseUri, final LoadingOptions loadingOptions) {
22
    final Matcher m = TYPE_DSL_REGEX.matcher(doc_);
1✔
23
    if (m.matches()) {
1✔
24
      final String first =
1✔
25
          loadingOptions.expandUrl(m.group(1), baseUri, false, true, this.refScope);
1✔
26
      Object second = null;
1✔
27
      Object third = null;
1✔
28
      if (m.group(2) != null && m.group(2).length() > 0) {
1✔
29
        HashMap<String, Object> resolvedMap = new HashMap<String, Object>();
1✔
30
        resolvedMap.put("type", "array");
1✔
31
        resolvedMap.put("items", first);
1✔
32
        second = resolvedMap;
1✔
33
      }
34
      if (m.group(3) != null && m.group(3).length() > 0) {
1✔
35
        third = Arrays.asList("null", second != null ? second : first);
1✔
36
      }
37
      if (third != null) {
1✔
38
        return third;
1✔
39
      } else {
40
        return second != null ? second : first;
1✔
41
      }
42
    } else {
NEW
43
      return doc_;
×
44
    }
45
  }
46

47
  public T load(
48
      final Object doc_,
49
      final String baseUri,
50
      final LoadingOptions loadingOptions,
51
      final String docRoot) {
52
    Object doc = doc_;
1✔
53
    if (doc instanceof List) {
1✔
54
      final List<Object> docList = (List<Object>) doc;
1✔
55
      final List<Object> r = new ArrayList<Object>();
1✔
56
      for (final Object d : docList) {
1✔
57
        if (d instanceof String) {
1✔
58
          Object resolved = this.resolve((String) d, baseUri, loadingOptions);
1✔
59
          if (resolved instanceof List) {
1✔
NEW
60
            List<Object> resolvedList = (List<Object>) resolved;
×
NEW
61
            for (Object i : resolvedList) {
×
NEW
62
              if (!r.contains(i)) {
×
NEW
63
                r.add(i);
×
64
              }
NEW
65
            }
×
NEW
66
          } else {
×
67
            if (!r.contains(resolved)) {
1✔
68
              r.add(resolved);
1✔
69
            }
70
          }
71
        } else {
1✔
72
          r.add(d);
1✔
73
        }
74
      }
1✔
75
      doc = docList;
1✔
76
    } else if (doc instanceof String) {
1✔
77
      doc = this.resolve((String) doc, baseUri, loadingOptions);
1✔
78
    }
79
    return this.innerLoader.load(doc, baseUri, loadingOptions);
1✔
80
  }
81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc