Skip to content

Commit 7ab3cd8

Browse files
committed
Ensure consistent type in ternary for C# compilation
1 parent d6d1ebf commit 7ab3cd8

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/main/java/org/zwobble/mammoth/internal/docx/DisabledFileReader.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import java.io.InputStream;
55

66
public class DisabledFileReader implements FileReader {
7+
public static final FileReader INSTANCE = new DisabledFileReader();
8+
9+
private DisabledFileReader() {}
10+
711
@Override
812
public InputStream getInputStream(String uri) throws IOException {
913
throw new IOException("could not open external image '" + uri + "': external file access is disabled");

src/main/java/org/zwobble/mammoth/internal/docx/DocumentReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public static InternalResult<Document> readDocument(
3434
ContentTypes contentTypes = readContentTypes(zipFile);
3535

3636
FileReader fileReader = externalFileAccess
37-
? new PathRelativeFileReader(path)
38-
: new DisabledFileReader();
37+
? PathRelativeFileReader.relativeTo(path)
38+
: DisabledFileReader.INSTANCE;
3939

4040
PartWithBodyReader partReader = new PartWithBodyReader(zipFile, contentTypes, fileReader, numbering, styles);
4141
return InternalResult.flatMap(

src/main/java/org/zwobble/mammoth/internal/docx/PathRelativeFileReader.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
import java.util.Optional;
99

1010
public class PathRelativeFileReader implements FileReader {
11+
public static FileReader relativeTo(Optional<Path> path) {
12+
return new PathRelativeFileReader(path);
13+
}
14+
1115
private final Optional<Path> path;
1216

13-
public PathRelativeFileReader(Optional<Path> path) {
17+
private PathRelativeFileReader(Optional<Path> path) {
1418
this.path = path;
1519
}
1620

0 commit comments

Comments
 (0)