Skip to content

Commit

Permalink
Changed wording from "entity" to "resource" (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
yelouarti authored Oct 22, 2024
1 parent a9a2337 commit 5ade644
Show file tree
Hide file tree
Showing 25 changed files with 828 additions and 815 deletions.
2 changes: 1 addition & 1 deletion .github/badges/version.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.13.0]

## Changed

* Changed wording from "entity" to "resource" when addressing objects that are part of/make out the hal-document

## [0.12.0]

### Changed
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=de.kamillionlabs
name=hateoflux
version=0.12.0
version=0.13.0

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,75 +18,75 @@

package de.kamillionlabs.hateoflux.assembler;

import de.kamillionlabs.hateoflux.model.hal.HalEntityWrapper;
import de.kamillionlabs.hateoflux.model.hal.HalListWrapper;
import de.kamillionlabs.hateoflux.model.hal.HalPageInfo;
import de.kamillionlabs.hateoflux.model.hal.HalResourceWrapper;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.web.server.ServerWebExchange;

import java.util.List;

/**
* Interface for managing the transformation of standalone entities into HAL-compliant representations,
* supplemented with hypermedia links. This interface facilitates the direct enhancement of entities with the necessary
* fields and structure to comply with HAL standards, enabling entities to become HAL-compliant.
* Interface for managing the transformation of standalone resources into HAL-compliant representations,
* supplemented with hypermedia links. This interface facilitates the direct enhancement of resources with the necessary
* fields and structure to comply with HAL standards, enabling resources to become HAL-compliant.
*
* <p> Core functionalities include:
* <ul>
* <li>Directly enhancing entities to meet HAL structure requirements.</li>
* <li>Appending hypermedia links to entities to support navigability and resource interaction in a HAL-based
* <li>Directly enhancing resources to meet HAL structure requirements.</li>
* <li>Appending hypermedia links to resources to support navigability and resource interaction in a HAL-based
* API.</li>
* <li>Supporting pagination when wrapping lists of entities to provide structured navigation across large
* <li>Supporting pagination when wrapping lists of resources to provide structured navigation across large
* datasets.</li>
* </ul>
* <p>
* This interface abstracts the tasks associated with modifying entities to fit HAL specifications, streamlining the
* creation of HAL-compliant entity representations.
* This interface abstracts the tasks associated with modifying resources to fit HAL specifications, streamlining the
* creation of HAL-compliant resource representations.
*
* <p>See also:
* <ul>
* <li>{@link EmbeddingHalWrapperAssembler} - for imperative (non-reactive) handling of entities <b>with</b>
* embedded entities.</li>
* <li>{@link ReactiveEmbeddingHalWrapperAssembler} - for reactive <b>and</b> imperative handling of entities
* <b>with</b> embedded entities.</li>
* <li>{@link EmbeddingHalWrapperAssembler} - for imperative (non-reactive) handling of resources <b>with</b>
* embedded resources.</li>
* <li>{@link ReactiveEmbeddingHalWrapperAssembler} - for reactive <b>and</b> imperative handling of resources
* <b>with</b> embedded resources.</li>
* <li>{@link ReactiveFlatHalWrapperAssembler} - for reactive <b>and</b> imperative handling of standalone
* entities <b>without</b> embedded entities.</li>
* resources <b>without</b> embedded resources.</li>
* </ul>
*
* @param <EntityT>
* @param <ResourceT>
* the type of the object being wrapped, which contains the main data
* @author Younes El Ouarti
*/
public non-sealed interface FlatHalWrapperAssembler<EntityT> extends
SealedEntityLinkAssemblerModule<EntityT>,
SealedEntityListAssemblerModule<EntityT, Void> {
public non-sealed interface FlatHalWrapperAssembler<ResourceT> extends
SealedResourceLinkAssemblerModule<ResourceT>,
SealedResourceListAssemblerModule<ResourceT, Void> {


/**
* Wraps a list of entities into a {@link HalListWrapper}, enhancing them with hypermedia links as defined by the
* Wraps a list of resources into a {@link HalListWrapper}, enhancing them with hypermedia links as defined by the
* assembler.
*
* @param entitiesToWrap
* the list of entities to be wrapped
* @param resourcesToWrap
* the list of resources to be wrapped
* @param exchange
* provides the context of the current web exchange, such as the base URL
* @return a {@link HalListWrapper} that includes the wrapped entities enhanced with hypermedia links
* @return a {@link HalListWrapper} that includes the wrapped resources enhanced with hypermedia links
*
* @see #wrapInListWrapper(List, long, int, Long, ServerWebExchange)
* @see #wrapInListWrapper(List, HalPageInfo, ServerWebExchange)
*/
default HalListWrapper<EntityT, Void> wrapInListWrapper(@NonNull List<EntityT> entitiesToWrap,
ServerWebExchange exchange) {
return wrapInListWrapper(entitiesToWrap, null, exchange);
default HalListWrapper<ResourceT, Void> wrapInListWrapper(@NonNull List<ResourceT> resourcesToWrap,
ServerWebExchange exchange) {
return wrapInListWrapper(resourcesToWrap, null, exchange);
}

/**
* Wraps a list of entities into a {@link HalListWrapper} with pagination details, enhancing them with hypermedia
* Wraps a list of resources into a {@link HalListWrapper} with pagination details, enhancing them with hypermedia
* links as defined by the assembler.
*
* @param entitiesToWrap
* the list of entities to be wrapped
* @param resourcesToWrap
* the list of resources to be wrapped
* @param totalElements
* the total number of elements across all pages
* @param pageSize
Expand All @@ -95,47 +95,48 @@ default HalListWrapper<EntityT, Void> wrapInListWrapper(@NonNull List<EntityT> e
* the starting offset of the page, if specified
* @param exchange
* provides the context of the current web exchange, such as the base URL
* @return a {@link HalListWrapper} that includes the wrapped entities enhanced with hypermedia links, along with
* @return a {@link HalListWrapper} that includes the wrapped resources enhanced with hypermedia links, along with
* pagination information
*
* @see #wrapInListWrapper(List, HalPageInfo, ServerWebExchange)
* @see #wrapInListWrapper(List, ServerWebExchange)
*/
default HalListWrapper<EntityT, Void> wrapInListWrapper(@NonNull List<EntityT> entitiesToWrap,
long totalElements,
int pageSize,
@Nullable Long offset,
ServerWebExchange exchange) {
HalPageInfo pageInfo = HalPageInfo.assemble(entitiesToWrap, totalElements, pageSize, offset);
return wrapInListWrapper(entitiesToWrap, pageInfo, exchange);
default HalListWrapper<ResourceT, Void> wrapInListWrapper(@NonNull List<ResourceT> resourcesToWrap,
long totalElements,
int pageSize,
@Nullable Long offset,
ServerWebExchange exchange) {
HalPageInfo pageInfo = HalPageInfo.assemble(resourcesToWrap, totalElements, pageSize, offset);
return wrapInListWrapper(resourcesToWrap, pageInfo, exchange);
}

/**
* Wraps a list of entities into a {@link HalListWrapper}, optionally including pagination information, and enhances
* Wraps a list of resources into a {@link HalListWrapper}, optionally including pagination information, and
* enhances
* them with hypermedia links as defined by the assembler.
*
* @param entitiesToWrap
* the list of entities to be wrapped
* @param resourcesToWrap
* the list of resources to be wrapped
* @param pageInfo
* optional pagination information to include in the wrapper
* @param exchange
* provides the context of the current web exchange, such as the base URL
* @return a {@link HalListWrapper} that includes the wrapped entities enhanced with hypermedia links, and
* @return a {@link HalListWrapper} that includes the wrapped resources enhanced with hypermedia links, and
* optionally pagination details
*
* @see #wrapInListWrapper(List, long, int, Long, ServerWebExchange)
* @see #wrapInListWrapper(List, ServerWebExchange)
*/
default HalListWrapper<EntityT, Void> wrapInListWrapper(@NonNull List<EntityT> entitiesToWrap,
@Nullable HalPageInfo pageInfo,
ServerWebExchange exchange) {
List<HalEntityWrapper<EntityT, Void>> listOfWrappedEntities =
entitiesToWrap.stream()
.map(entity -> wrapInEntityWrapper(entity, exchange))
default HalListWrapper<ResourceT, Void> wrapInListWrapper(@NonNull List<ResourceT> resourcesToWrap,
@Nullable HalPageInfo pageInfo,
ServerWebExchange exchange) {
List<HalResourceWrapper<ResourceT, Void>> listOfWrappedResources =
resourcesToWrap.stream()
.map(resource -> wrapInResourceWrapper(resource, exchange))
.toList();

HalListWrapper<EntityT, Void> result = HalListWrapper.wrap(listOfWrappedEntities)
.withLinks(buildLinksForEntityList(exchange));
HalListWrapper<ResourceT, Void> result = HalListWrapper.wrap(listOfWrappedResources)
.withLinks(buildLinksForResourceList(exchange));

if (pageInfo == null) {
return result;
Expand All @@ -145,19 +146,19 @@ default HalListWrapper<EntityT, Void> wrapInListWrapper(@NonNull List<EntityT> e
}

/**
* Wraps a single entity in a {@link HalEntityWrapper} and enhances it with hypermedia links as defined by the
* Wraps a single resource in a {@link HalResourceWrapper} and enhances it with hypermedia links as defined by the
* assembler.
*
* @param entityToWrap
* the entity to wrap
* @param resourceToWrap
* the resource to wrap
* @param exchange
* provides the context of the current web exchange, such as the base URL
* @return a {@link HalEntityWrapper} that includes the wrapped entity enhanced with hypermedia links
* @return a {@link HalResourceWrapper} that includes the wrapped resource enhanced with hypermedia links
*/
default HalEntityWrapper<EntityT, Void> wrapInEntityWrapper(@NonNull EntityT entityToWrap,
ServerWebExchange exchange) {
return HalEntityWrapper.wrap(entityToWrap)
.withLinks(buildLinksForEntity(entityToWrap, exchange));
default HalResourceWrapper<ResourceT, Void> wrapInResourceWrapper(@NonNull ResourceT resourceToWrap,
ServerWebExchange exchange) {
return HalResourceWrapper.wrap(resourceToWrap)
.withLinks(buildLinksForResource(resourceToWrap, exchange));
}

}
Loading

0 comments on commit 5ade644

Please sign in to comment.