All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ca.gc.aafc.dina.dto.JsonApiDto Maven / Gradle / Ivy

The newest version!
package ca.gc.aafc.dina.dto;

import java.util.List;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Singular;

/**
 * Contains a DTO with its optional relationships.
 */
@AllArgsConstructor
@Builder
@Getter
public class JsonApiDto {

  private final D dto;

  @Singular
  private final Map relationships;

  /**
   * Sealed interface since there is only 4 expected type of relationships.
   */
  public sealed interface RelationshipBase permits
    RelationshipToOne, RelationshipToMany, RelationshipToOneExternal, RelationshipManyExternal {
  }

  @AllArgsConstructor
  @Builder
  @Getter
  public static final class RelationshipToOne implements RelationshipBase {
    private JsonApiResource included;
  }

  @AllArgsConstructor
  @Builder
  @Getter
  public static final class RelationshipToMany implements RelationshipBase {
    private List included;
  }

  @AllArgsConstructor
  @Builder
  @Getter
  public static final class RelationshipToOneExternal implements RelationshipBase {
    private JsonApiExternalResource included;
  }

  @AllArgsConstructor
  @Builder
  @Getter
  public static final class RelationshipManyExternal implements RelationshipBase {
    private List included;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy