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

knowledgepixels / nanodash / 19032518047

03 Nov 2025 11:10AM UTC coverage: 14.338% (-0.9%) from 15.251%
19032518047

push

github

web-flow
Merge pull request #269 from knowledgepixels/245-local-uri-without-slashes-or-hashes

Add check for local URIs to ensure that they don't contain slashes or hashes

518 of 4518 branches covered (11.47%)

Branch coverage included in aggregate %.

1333 of 8392 relevant lines covered (15.88%)

0.71 hits per line

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

83.33
src/main/java/com/knowledgepixels/nanodash/LocalUri.java
1
package com.knowledgepixels.nanodash;
2

3
import org.eclipse.rdf4j.model.base.AbstractIRI;
4

5
import java.util.Objects;
6

7
/**
8
 * A simple implementation of IRI for local URIs. Local URIs have a fixed prefix "local:" and a local name.
9
 */
10
public class LocalUri extends AbstractIRI {
11
    /**
12
     * The prefix for local URIs.
13
     */
14
    public static final String PREFIX = "local:";
15
    private final String localName;
16

17
    private LocalUri(String localName) {
2✔
18
        this.localName = localName;
3✔
19
    }
1✔
20

21
    /**
22
     * Factory method to create a LocalUri instance.
23
     *
24
     * @param localName the local name to be appended to the "local:" prefix.
25
     * @return a new LocalUri instance.
26
     */
27
    public static LocalUri of(String localName) {
28
        if (localName == null || localName.isBlank()) {
5✔
29
            throw new IllegalArgumentException("Local name cannot be null or blank");
5✔
30
        }
31
        if (localName.contains("#")) {
4✔
32
            throw new IllegalArgumentException("Local name cannot contain '#'");
5✔
33
        }
34
        return new LocalUri(localName);
5✔
35
    }
36

37
    @Override
38
    public String getNamespace() {
39
        return null;
2✔
40
    }
41

42
    @Override
43
    public String getLocalName() {
44
        return this.localName;
3✔
45
    }
46

47
    @Override
48
    public boolean equals(Object o) {
49
        if (this == o) {
3!
50
            return true;
×
51
        }
52
        if (o == null || getClass() != o.getClass()) {
7!
53
            return false;
×
54
        }
55
        LocalUri localUri = (LocalUri) o;
3✔
56
        return Objects.equals(localName, localUri.localName);
6✔
57
    }
58

59
    @Override
60
    public int hashCode() {
61
        return Objects.hash(localName);
9✔
62
    }
63

64
    @Override
65
    public String stringValue() {
66
        return PREFIX + localName;
4✔
67
    }
68

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