This repository has been archived by the owner on Dec 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Document#storage for easier usage of the storage system
- Loading branch information
Showing
8 changed files
with
118 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...hub/derrop/documents/DocumentStorage.java → ...op/documents/storage/DocumentStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/github/derrop/documents/storage/SpecificDocumentStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.github.derrop.documents.storage; | ||
|
||
import com.github.derrop.documents.Document; | ||
|
||
import java.io.*; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
public interface SpecificDocumentStorage { | ||
|
||
Document document(); | ||
|
||
SpecificDocumentStorage write(OutputStream outputStream); | ||
|
||
SpecificDocumentStorage write(File file); | ||
|
||
SpecificDocumentStorage write(Path path); | ||
|
||
String serializeToString(); | ||
|
||
SpecificDocumentStorage write(Writer writer); | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/com/github/derrop/documents/storage/WrappedSpecificDocumentStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.github.derrop.documents.storage; | ||
|
||
import com.github.derrop.documents.Document; | ||
|
||
import java.io.File; | ||
import java.io.OutputStream; | ||
import java.io.Writer; | ||
import java.nio.file.Path; | ||
|
||
public class WrappedSpecificDocumentStorage implements SpecificDocumentStorage { | ||
|
||
private final DocumentStorage storage; | ||
private final Document document; | ||
|
||
public WrappedSpecificDocumentStorage(Document document, DocumentStorage storage) { | ||
this.document = document; | ||
this.storage = storage; | ||
} | ||
|
||
@Override | ||
public Document document() { | ||
return this.document; | ||
} | ||
|
||
@Override | ||
public SpecificDocumentStorage write(OutputStream outputStream) { | ||
this.storage.write(this.document, outputStream); | ||
return this; | ||
} | ||
|
||
@Override | ||
public SpecificDocumentStorage write(File file) { | ||
this.storage.write(this.document, file); | ||
return this; | ||
} | ||
|
||
@Override | ||
public SpecificDocumentStorage write(Path path) { | ||
this.storage.write(this.document, path); | ||
return this; | ||
} | ||
|
||
@Override | ||
public String serializeToString() { | ||
return this.storage.toString(this.document); | ||
} | ||
|
||
@Override | ||
public SpecificDocumentStorage write(Writer writer) { | ||
this.storage.write(this.document, writer); | ||
return this; | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...derrop/documents/YamlDocumentStorage.java → ...ocuments/storage/YamlDocumentStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters