Skip to content

Commit

Permalink
Merge pull request #30569 from Sgitario/30515
Browse files Browse the repository at this point in the history
Add default implementation for REST Data interfaces
  • Loading branch information
Sgitario authored Jan 25, 2023
2 parents 34c10ca + fa39b9a commit 17d010d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
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");
}
}

0 comments on commit 17d010d

Please sign in to comment.