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

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

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


import java.util.function.BiFunction;
import lombok.AllArgsConstructor;
import lombok.Builder;

/**
 * Represents the meta section of a JSON:API response.
 *
 */
@Builder
@AllArgsConstructor
public final class JsonApiMeta {

  public static final String RESOURCE_COUNT = "totalResourceCount";
  public static final String MODULE_VERSION = "moduleVersion";

  private Integer totalResourceCount = null;
  private String moduleVersion = null;

  private JsonApiMeta() {
  }

  /**
   * Call the provided method to set the metadata per key/value.
   * @param metaSetter
   */
  public void populateMeta(BiFunction metaSetter) {
    if (totalResourceCount != null) {
      metaSetter.apply(RESOURCE_COUNT, totalResourceCount);
    }

    if (moduleVersion != null) {
      metaSetter.apply(MODULE_VERSION, moduleVersion);
    }
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy