Skip to content

Commit

Permalink
Minor Table.View* doc and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nvamelichev committed Mar 5, 2024
1 parent c915cb3 commit 473272d
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions repository/src/main/java/tech/ydb/yoj/repository/db/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ default <ID extends Entity.Id<T>> Stream<ID> readTableIds() {

default FirstLevelCache getFirstLevelCache() {
return null;
};
}

@NonNull
default <X extends Exception> T find(Entity.Id<T> id, Supplier<? extends X> throwIfAbsent) throws X {
Expand Down Expand Up @@ -350,23 +350,38 @@ default TableQueryBuilder<T> query() {
@Deprecated
void update(Entity.Id<T> id, Changeset changeset);

/**
* Base interface for <em>views</em>, that is, arbitrary subsets of {@link Entity} fields.
*
* @see ViewId
*/
interface View {
}

interface ViewId<T extends Entity<T>> extends View {
Entity.Id<T> getId();
/**
* Base interface for ID-aware views, that is, subsets of {@link Entity} fields
* that contain the Entity's ID.
*
* @param <E> entity type
* @see RecordViewId
*/
interface ViewId<E extends Entity<E>> extends View {
Entity.Id<E> getId();
}

/**
* Base interface for ID-aware table views that are Java {@link java.lang.Record records}.
* <p>Forwards {@link ViewId#getId() ViewId's getId() method} to the record's {@code id()} accessor.
* Base interface for ID-aware views that are implemented as {@link java.lang.Record Java Records}.
* <p>Forwards {@link ViewId#getId() ViewId's getId() method} to the record's {@code id()} accessor,
* so you don't need to override the {@code getId()} method yourself.
*
* @param <E> entity type
* @see ViewId
*/
interface RecordViewId<T extends Entity<T>> extends ViewId<T> {
Entity.Id<T> id();
interface RecordViewId<E extends Entity<E>> extends ViewId<E> {
Entity.Id<E> id();

default Entity.Id<T> getId() {
@Override
default Entity.Id<E> getId() {
return id();
}
}
Expand Down

0 comments on commit 473272d

Please sign in to comment.