Skip to content
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

Add default implementation for REST Data interfaces #30569

Merged
merged 1 commit into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ public interface ReactiveRestDataResource<Entity, ID> {
* @param sort Panache sort instance that should be used in a query.
* @return A response with an entities JSON array.
*/
Uni<List<Entity>> list(Page page, Sort sort);
default Uni<List<Entity>> list(Page page, Sort sort) {
throw new RuntimeException("Not implemented yet");
}

/**
* @return the total number of entities.
*/
Uni<Long> count();
default Uni<Long> count() {
throw new RuntimeException("Not implemented yet");
}

/**
* Return an entity as a JSON object.
Expand All @@ -40,7 +44,9 @@ public interface ReactiveRestDataResource<Entity, ID> {
* @param id Entity identifier.
* @return A response with a JSON object representing an entity.
*/
Uni<Entity> get(ID id);
default Uni<Entity> get(ID id) {
throw new RuntimeException("Not implemented yet");
}

/**
* Create a new entity from the provided JSON object.
Expand All @@ -50,7 +56,9 @@ public interface ReactiveRestDataResource<Entity, ID> {
* @param entity Entity to be created
* @return A response with a JSON object representing an entity and a location header of the new entity.
*/
Uni<Entity> add(Entity entity);
default Uni<Entity> add(Entity entity) {
throw new RuntimeException("Not implemented yet");
}

/**
* Update an existing entity or create a new one from the provided JSON object.
Expand All @@ -62,13 +70,17 @@ public interface ReactiveRestDataResource<Entity, ID> {
* @return A response with no-content status in case of the update.
* A response with a JSON object representing an entity and a location header in case of the create.
*/
Uni<Entity> update(ID id, Entity entity);
default Uni<Entity> update(ID id, Entity entity) {
throw new RuntimeException("Not implemented yet");
}

/**
* Delete an entity.
*
* @param id Entity identifier.
* @return A boolean indicated whether the entity was deleted or not.
*/
Uni<Boolean> delete(ID id);
default Uni<Boolean> delete(ID id) {
throw new RuntimeException("Not implemented yet");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ public interface RestDataResource<Entity, ID> {
* @param sort Panache sort instance that should be used in a query.
* @return A response with an entities JSON array.
*/
List<Entity> list(Page page, Sort sort);
default List<Entity> list(Page page, Sort sort) {
throw new RuntimeException("Not implemented yet");
}

/**
* @return the total number of entities.
*/
long count();
default long count() {
throw new RuntimeException("Not implemented yet");
}

/**
* Return an entity as a JSON object.
Expand All @@ -39,7 +43,9 @@ public interface RestDataResource<Entity, ID> {
* @param id Entity identifier.
* @return A response with a JSON object representing an entity.
*/
Entity get(ID id);
default Entity get(ID id) {
throw new RuntimeException("Not implemented yet");
}

/**
* Create a new entity from the provided JSON object.
Expand All @@ -49,7 +55,9 @@ public interface RestDataResource<Entity, ID> {
* @param entity Entity to be created
* @return A response with a JSON object representing an entity and a location header of the new entity.
*/
Entity add(Entity entity);
default Entity add(Entity entity) {
throw new RuntimeException("Not implemented yet");
}

/**
* Update an existing entity or create a new one from the provided JSON object.
Expand All @@ -61,13 +69,17 @@ public interface RestDataResource<Entity, ID> {
* @return A response with no-content status in case of the update.
* A response with a JSON object representing an entity and a location header in case of the create.
*/
Entity update(ID id, Entity entity);
default Entity update(ID id, Entity entity) {
throw new RuntimeException("Not implemented yet");
}

/**
* Delete an entity.
*
* @param id Entity identifier.
* @return A boolean indicated whether the entity was deleted or not.
*/
boolean delete(ID id);
default boolean delete(ID id) {
throw new RuntimeException("Not implemented yet");
}
}