Package com.linecorp.centraldogma.common
Interface Change<T>
public interface Change<T>
A modification of an individual
Entry
.-
Method Summary
Modifier and TypeMethodDescriptioncontent()
Returns the textual representation ofcontent()
.fromDirectory
(Path sourcePath, String targetPath) static Change
<?> Creates a newChange
from the file at the specified location.ofJsonPatch
(String path, JsonNode jsonPatchNode) Returns a newly-createdChange
whose type isChangeType.APPLY_JSON_PATCH
.ofJsonPatch
(String path, JsonNode oldJsonNode, JsonNode newJsonNode) Returns a newly-createdChange
whose type isChangeType.APPLY_JSON_PATCH
.ofJsonPatch
(String path, String jsonPatchText) Returns a newly-createdChange
whose type isChangeType.APPLY_JSON_PATCH
.ofJsonPatch
(String path, String oldJsonText, String newJsonText) Returns a newly-createdChange
whose type isChangeType.APPLY_JSON_PATCH
.ofJsonUpsert
(String path, JsonNode jsonNode) Returns a newly-createdChange
whose type isChangeType.UPSERT_JSON
.ofJsonUpsert
(String path, String jsonText) Returns a newly-createdChange
whose type isChangeType.UPSERT_JSON
.Returns a newly-createdChange
whose type isChangeType.REMOVE
.Returns a newly-createdChange
whose type isChangeType.RENAME
.ofTextPatch
(String path, String textPatch) Returns a newly-createdChange
whose type isChangeType.APPLY_TEXT_PATCH
.ofTextPatch
(String path, String oldText, String newText) Returns a newly-createdChange
whose type isChangeType.APPLY_TEXT_PATCH
.ofTextUpsert
(String path, String text) Returns a newly-createdChange
whose type isChangeType.UPSERT_TEXT
.path()
Returns the path of theChange
.type()
Returns the type of theChange
.
-
Method Details
-
ofTextUpsert
Returns a newly-createdChange
whose type isChangeType.UPSERT_TEXT
.Note that you should use
ofJsonUpsert(String, String)
if the specifiedpath
ends with".json"
. TheofJsonUpsert(String, String)
will check that the giventext
is a valid JSON.- Parameters:
path
- the path of the filetext
- the content of the file- Throws:
ChangeFormatException
- if the path ends with".json"
-
ofJsonUpsert
Returns a newly-createdChange
whose type isChangeType.UPSERT_JSON
.- Parameters:
path
- the path of the filejsonText
- the content of the file- Throws:
ChangeFormatException
- if the specifiedjsonText
is not a valid JSON
-
ofJsonUpsert
Returns a newly-createdChange
whose type isChangeType.UPSERT_JSON
.- Parameters:
path
- the path of the filejsonNode
- the content of the file
-
ofRemoval
Returns a newly-createdChange
whose type isChangeType.REMOVE
.- Parameters:
path
- the path of the file to remove
-
ofRename
Returns a newly-createdChange
whose type isChangeType.RENAME
.- Parameters:
oldPath
- the old path of the filenewPath
- the new path of the file
-
ofTextPatch
Returns a newly-createdChange
whose type isChangeType.APPLY_TEXT_PATCH
.Note that you should use
ofJsonPatch(String, String, String)
if the specifiedpath
ends with".json"
. TheofJsonUpsert(String, String)
will check that the givenoldText
andnewText
are valid JSONs.- Parameters:
path
- the path of the fileoldText
- the old content of the filenewText
- the new content of the file- Throws:
ChangeFormatException
- if the path ends with".json"
-
ofTextPatch
Returns a newly-createdChange
whose type isChangeType.APPLY_TEXT_PATCH
.Note that you should use
ofJsonPatch(String, String)
if the specifiedpath
ends with".json"
. TheofJsonUpsert(String, String)
will check that the giventextPatch
is a valid JSON.- Parameters:
path
- the path of the filetextPatch
- the patch in unified format- Throws:
ChangeFormatException
- if the path ends with".json"
-
ofJsonPatch
Returns a newly-createdChange
whose type isChangeType.APPLY_JSON_PATCH
.- Parameters:
path
- the path of the fileoldJsonText
- the old content of the filenewJsonText
- the new content of the file- Throws:
ChangeFormatException
- if the specifiedoldJsonText
ornewJsonText
is not a valid JSON
-
ofJsonPatch
static Change<JsonNode> ofJsonPatch(String path, @Nullable JsonNode oldJsonNode, JsonNode newJsonNode) Returns a newly-createdChange
whose type isChangeType.APPLY_JSON_PATCH
.- Parameters:
path
- the path of the fileoldJsonNode
- the old content of the filenewJsonNode
- the new content of the file
-
ofJsonPatch
Returns a newly-createdChange
whose type isChangeType.APPLY_JSON_PATCH
.- Parameters:
path
- the path of the filejsonPatchText
- the patch in JSON patch format- Throws:
ChangeFormatException
- if the specifiedjsonPatchText
is not a valid JSON
-
ofJsonPatch
Returns a newly-createdChange
whose type isChangeType.APPLY_JSON_PATCH
.- Parameters:
path
- the path of the filejsonPatchNode
- the patch in JSON patch format
-
fromDirectory
-
fromFile
Creates a newChange
from the file at the specified location.- Parameters:
sourcePath
- the path to the regular file to importtargetPath
- the target path of the importedChange
-
type
ChangeType type()Returns the type of theChange
. -
path
String path()Returns the path of theChange
. -
content
-
contentAsText
Returns the textual representation ofcontent()
.
-