-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
23 changed files
with
293 additions
and
7 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
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
23 changes: 23 additions & 0 deletions
23
databind/src/main/java/tech/ydb/yoj/databind/converter/StringColumn.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,23 @@ | ||
package tech.ydb.yoj.databind.converter; | ||
|
||
import tech.ydb.yoj.databind.CustomValueType; | ||
import tech.ydb.yoj.databind.schema.Column; | ||
|
||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.ANNOTATION_TYPE; | ||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.RECORD_COMPONENT; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
/** | ||
* Alias for "want-it-to-be-string" columns | ||
* {@link StringValueConverter} | ||
*/ | ||
@Inherited | ||
@Retention(RUNTIME) | ||
@Target({FIELD, RECORD_COMPONENT, ANNOTATION_TYPE}) | ||
@Column(customValueType = @CustomValueType(columnClass = String.class, converter = StringValueConverter.class)) | ||
public @interface StringColumn {} |
23 changes: 23 additions & 0 deletions
23
databind/src/main/java/tech/ydb/yoj/databind/converter/StringValueType.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,23 @@ | ||
package tech.ydb.yoj.databind.converter; | ||
|
||
import tech.ydb.yoj.databind.CustomValueType; | ||
|
||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.ANNOTATION_TYPE; | ||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.RECORD_COMPONENT; | ||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
/** | ||
* Easy to use annotation to mark type as String based | ||
* {@link StringValueConverter} | ||
*/ | ||
@Inherited | ||
@Retention(RUNTIME) | ||
@Target({TYPE, FIELD, RECORD_COMPONENT, ANNOTATION_TYPE}) | ||
@CustomValueType(columnClass = String.class, converter = StringValueConverter.class) | ||
public @interface StringValueType {} |
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
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
19 changes: 19 additions & 0 deletions
19
repository-test/src/main/java/tech/ydb/yoj/repository/test/sample/model/VersionColumn.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,19 @@ | ||
package tech.ydb.yoj.repository.test.sample.model; | ||
|
||
import tech.ydb.yoj.databind.CustomValueType; | ||
import tech.ydb.yoj.databind.schema.Column; | ||
|
||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.ANNOTATION_TYPE; | ||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.RECORD_COMPONENT; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
@Inherited | ||
@Retention(RUNTIME) | ||
@Target({FIELD, RECORD_COMPONENT, ANNOTATION_TYPE}) | ||
@Column(customValueType = @CustomValueType(columnClass = Long.class, converter = Version.Converter.class)) | ||
public @interface VersionColumn {} |
26 changes: 26 additions & 0 deletions
26
...-test/src/main/java/tech/ydb/yoj/repository/test/sample/model/VersionedAliasedEntity.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,26 @@ | ||
package tech.ydb.yoj.repository.test.sample.model; | ||
|
||
import tech.ydb.yoj.databind.converter.StringColumn; | ||
import tech.ydb.yoj.repository.db.Entity; | ||
import tech.ydb.yoj.repository.db.RecordEntity; | ||
import tech.ydb.yoj.repository.test.sample.model.annotations.Sha256; | ||
|
||
import java.util.UUID; | ||
|
||
public record VersionedAliasedEntity( | ||
Id id, | ||
@VersionColumn | ||
Version version2, | ||
@StringColumn | ||
UUID uuid | ||
) implements RecordEntity<VersionedAliasedEntity> { | ||
public record Id( | ||
String value, | ||
@VersionColumn | ||
Version version, | ||
@StringColumn | ||
UUID uuidId, | ||
Sha256 hash | ||
) implements Entity.Id<VersionedAliasedEntity> { | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...tory-test/src/main/java/tech/ydb/yoj/repository/test/sample/model/annotations/Digest.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,36 @@ | ||
package tech.ydb.yoj.repository.test.sample.model.annotations; | ||
|
||
import java.util.Objects; | ||
|
||
|
||
public class Digest implements YojString { | ||
private final String algorithm; | ||
private final String digest; | ||
|
||
protected Digest(String algorithm, String digest) { | ||
this.algorithm = algorithm; | ||
this.digest = digest; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return algorithm + ":" + digest; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object object) { | ||
if (this == object) { | ||
return true; | ||
} | ||
if (object == null || getClass() != object.getClass()) { | ||
return false; | ||
} | ||
Digest digest1 = (Digest) object; | ||
return Objects.equals(algorithm, digest1.algorithm) && Objects.equals(digest, digest1.digest); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(algorithm, digest); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...tory-test/src/main/java/tech/ydb/yoj/repository/test/sample/model/annotations/Sha256.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,17 @@ | ||
package tech.ydb.yoj.repository.test.sample.model.annotations; | ||
|
||
public class Sha256 extends Digest { | ||
private static final String SHA_256 = "SHA256"; | ||
|
||
public Sha256(String digest) { | ||
super(SHA_256, digest); | ||
} | ||
|
||
public static Sha256 valueOf(String value) { | ||
String[] parsed = value.split(":"); | ||
if (parsed.length != 2 || !SHA_256.equals(parsed[0])) { | ||
throw new IllegalArgumentException(); | ||
} | ||
return new Sha256(parsed[1]); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...y-test/src/main/java/tech/ydb/yoj/repository/test/sample/model/annotations/YojString.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,7 @@ | ||
package tech.ydb.yoj.repository.test.sample.model.annotations; | ||
|
||
import tech.ydb.yoj.databind.converter.StringValueType; | ||
|
||
@StringValueType | ||
public interface YojString { | ||
} |
Oops, something went wrong.