Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce WriteResult interface which replaces Repository.Success
Allow more fine-grained statistics after a write operation
- Loading branch information
1 parent
bad18bc
commit f532b29
Showing
11 changed files
with
120 additions
and
29 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
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
49 changes: 49 additions & 0 deletions
49
criteria/common/src/org/immutables/criteria/WriteResult.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,49 @@ | |||
/* | |||
* Copyright 2019 Immutables Authors and Contributors | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
package org.immutables.criteria; | |||
|
|||
import java.util.OptionalLong; | |||
|
|||
/** | |||
* Result of a <i>successful</i> write operation. It is up to back-end to provide | |||
* some, all or none of exposed statistics. | |||
*/ | |||
public interface WriteResult { | |||
|
|||
/** | |||
* Number of records after insert operation | |||
* | |||
* @return number of inserted records. empty optional if unknown | |||
*/ | |||
OptionalLong insertedCount(); | |||
|
|||
|
|||
/** | |||
* Number of records deleted after a write operation | |||
* | |||
* @return number of deleted records. empty optional if unknown or operation not supported. | |||
*/ | |||
OptionalLong deletedCount(); | |||
|
|||
/** | |||
* Number of records updated after a write operation | |||
* | |||
* @return number of deleted records. empty optional if unknown or operation not supported. | |||
*/ | |||
OptionalLong updatedCount(); | |||
|
|||
} |
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
46 changes: 46 additions & 0 deletions
46
criteria/common/src/org/immutables/criteria/adapter/UnknownWriteResult.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,46 @@ | |||
/* | |||
* Copyright 2019 Immutables Authors and Contributors | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
package org.immutables.criteria.adapter; | |||
|
|||
import org.immutables.criteria.WriteResult; | |||
|
|||
import java.util.OptionalLong; | |||
|
|||
/** | |||
* Used as a <b>null object</b> if backend can't provide information about a write operation | |||
*/ | |||
public final class UnknownWriteResult implements WriteResult { | |||
|
|||
public static final WriteResult INSTANCE = new UnknownWriteResult(); | |||
|
|||
private UnknownWriteResult() {} | |||
|
|||
@Override | |||
public OptionalLong insertedCount() { | |||
return OptionalLong.empty(); | |||
} | |||
|
|||
@Override | |||
public OptionalLong deletedCount() { | |||
return OptionalLong.empty(); | |||
} | |||
|
|||
@Override | |||
public OptionalLong updatedCount() { | |||
return OptionalLong.empty(); | |||
} | |||
} |
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
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