-
Notifications
You must be signed in to change notification settings - Fork 917
DDB Enhanced: Allow custom versioning #6019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RanVaknin
wants to merge
12
commits into
master
Choose a base branch
from
rvaknin/ddb-enhanced-client-versioned-record-custom-startAt
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
099236c
Adding annotation support
RanVaknin f0ccb3e
Making annotation values nullable to know if initial value is explici…
RanVaknin 086b769
Added changelog with attribution
RanVaknin de4a4f5
Fix checkstyle
RanVaknin 9a66e86
Adding japicmp excludes block
RanVaknin 6195af7
Adding additional test coverage to account for all isInitialVersion c…
RanVaknin 7cbf420
Removing logger config file
RanVaknin b787406
porting version from Integer to Long, removing refactoring
RanVaknin b7b79c2
refactoring and adding test coverage
RanVaknin 4de6ae4
adding annotation test
RanVaknin 48fec49
adding localstack test, removing optional from function signature
RanVaknin 38e83d3
fix checkstyle
RanVaknin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactoring and adding test coverage
- Loading branch information
commit b7b79c25ddc6ef6885311f8407a0cd5984167862
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
122 changes: 122 additions & 0 deletions
122
...re/amazon/awssdk/enhanced/dynamodb/functionaltests/models/ImmutableFakeVersionedItem.java
This file contains hidden or 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,122 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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 software.amazon.awssdk.enhanced.dynamodb.functionaltests.models; | ||
|
||
import static software.amazon.awssdk.enhanced.dynamodb.extensions.VersionedRecordExtension.AttributeTags.versionAttribute; | ||
import static software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey; | ||
|
||
import java.util.Objects; | ||
import software.amazon.awssdk.enhanced.dynamodb.TableMetadata; | ||
import software.amazon.awssdk.enhanced.dynamodb.TableSchema; | ||
import software.amazon.awssdk.enhanced.dynamodb.mapper.StaticImmutableTableSchema; | ||
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbImmutable; | ||
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbPartitionKey; | ||
|
||
@DynamoDbImmutable(builder = ImmutableFakeVersionedItem.Builder.class) | ||
public class ImmutableFakeVersionedItem { | ||
private final String id; | ||
private final String attribute; | ||
private final long version; | ||
|
||
private ImmutableFakeVersionedItem(Builder b) { | ||
this.id = b.id; | ||
this.attribute = b.attribute; | ||
this.version = b.version; | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public String attribute() { | ||
return attribute; | ||
} | ||
|
||
@DynamoDbPartitionKey | ||
public String id() { | ||
return id; | ||
} | ||
|
||
public long version() { | ||
return version; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
ImmutableFakeVersionedItem that = (ImmutableFakeVersionedItem) o; | ||
return version == that.version && Objects.equals(id, that.id) && Objects.equals(attribute, that.attribute); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id, attribute, version); | ||
} | ||
|
||
public static TableSchema<ImmutableFakeVersionedItem> getTableSchema() { | ||
return StaticImmutableTableSchema.builder(ImmutableFakeVersionedItem.class, ImmutableFakeVersionedItem.Builder.class) | ||
.newItemBuilder(ImmutableFakeVersionedItem::builder, ImmutableFakeVersionedItem.Builder::build) | ||
.addAttribute(String.class, a -> a.name("id") | ||
.getter(ImmutableFakeVersionedItem::id) | ||
.setter(ImmutableFakeVersionedItem.Builder::id) | ||
.tags(primaryPartitionKey())) | ||
.addAttribute(Long.class, a -> a.name("version") | ||
.getter(ImmutableFakeVersionedItem::version) | ||
.setter(ImmutableFakeVersionedItem.Builder::version) | ||
.tags(versionAttribute())) | ||
.addAttribute(String.class, a -> a.name("attribute") | ||
.getter(ImmutableFakeVersionedItem::attribute) | ||
.setter(ImmutableFakeVersionedItem.Builder::attribute)) | ||
.build(); | ||
} | ||
|
||
|
||
|
||
|
||
public static TableMetadata getTableMetadata() { | ||
return getTableSchema().tableMetadata(); | ||
} | ||
|
||
public static final class Builder { | ||
private String id; | ||
private String attribute; | ||
private long version; | ||
|
||
public Builder id(String id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
public Builder version(long version) { | ||
this.version = version; | ||
return this; | ||
} | ||
|
||
public Builder attribute(String attribute) { | ||
this.attribute = attribute; | ||
return this; | ||
} | ||
|
||
public ImmutableFakeVersionedItem build() { | ||
return new ImmutableFakeVersionedItem(this); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.