package com.airlock.iam.common.application.exception;

import ch.ergon.restal.jsonapi.document.request.RequestDocument;
import com.airlock.iam.base.api.domain.model.exception.ViolationException;
import java.util.Objects;

public class RequestDocumentAttributesMissingException extends ViolationException {
   public static <T> T checkAttributesPresent(RequestDocument<T> requestDocument) {
      Objects.requireNonNull(requestDocument, "Request document must not be null");
      T attributes = (T)requestDocument.getDataAttributes();
      if (attributes == null) {
         throw new RequestDocumentAttributesMissingException("Request document is missing \"attributes\"");
      } else {
         return attributes;
      }
   }

   public RequestDocumentAttributesMissingException(String message) {
      super(message);
   }
}
