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

com.finbourne.access.model.RequestDetails Maven / Gradle / Ivy

There is a newer version: 2.0.296
Show newest version
/*
 * FINBOURNE Access Management API
 *
 * Contact: [email protected]
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

package com.finbourne.access.model;

import java.util.Objects;
import com.finbourne.access.model.RequestedActionKey;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.openapitools.jackson.nullable.JsonNullable;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.finbourne.access.JSON;

/**
 * The details of the requested evaluation
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class RequestDetails {
  public static final String SERIALIZED_NAME_ACTION = "action";
  @SerializedName(SERIALIZED_NAME_ACTION)
  private RequestedActionKey action;

  public static final String SERIALIZED_NAME_FROM_EFFECTIVE_DATE = "fromEffectiveDate";
  @SerializedName(SERIALIZED_NAME_FROM_EFFECTIVE_DATE)
  private OffsetDateTime fromEffectiveDate;

  public static final String SERIALIZED_NAME_TO_EFFECTIVE_DATE = "toEffectiveDate";
  @SerializedName(SERIALIZED_NAME_TO_EFFECTIVE_DATE)
  private OffsetDateTime toEffectiveDate;

  public static final String SERIALIZED_NAME_FROM_AS_AT = "fromAsAt";
  @SerializedName(SERIALIZED_NAME_FROM_AS_AT)
  private OffsetDateTime fromAsAt;

  public static final String SERIALIZED_NAME_TO_AS_AT = "toAsAt";
  @SerializedName(SERIALIZED_NAME_TO_AS_AT)
  private OffsetDateTime toAsAt;

  public RequestDetails() {
  }

  public RequestDetails action(RequestedActionKey action) {
    
    this.action = action;
    return this;
  }

   /**
   * Get action
   * @return action
  **/
  @jakarta.annotation.Nonnull
  public RequestedActionKey getAction() {
    return action;
  }


  public void setAction(RequestedActionKey action) {
    this.action = action;
  }


  public RequestDetails fromEffectiveDate(OffsetDateTime fromEffectiveDate) {
    
    this.fromEffectiveDate = fromEffectiveDate;
    return this;
  }

   /**
   * The start date for the requested effective date range for the resource (if null, UtcNow)
   * @return fromEffectiveDate
  **/
  @jakarta.annotation.Nullable
  public OffsetDateTime getFromEffectiveDate() {
    return fromEffectiveDate;
  }


  public void setFromEffectiveDate(OffsetDateTime fromEffectiveDate) {
    this.fromEffectiveDate = fromEffectiveDate;
  }


  public RequestDetails toEffectiveDate(OffsetDateTime toEffectiveDate) {
    
    this.toEffectiveDate = toEffectiveDate;
    return this;
  }

   /**
   * The end date for the requested effective date range for the resource (if null, same as from date)
   * @return toEffectiveDate
  **/
  @jakarta.annotation.Nullable
  public OffsetDateTime getToEffectiveDate() {
    return toEffectiveDate;
  }


  public void setToEffectiveDate(OffsetDateTime toEffectiveDate) {
    this.toEffectiveDate = toEffectiveDate;
  }


  public RequestDetails fromAsAt(OffsetDateTime fromAsAt) {
    
    this.fromAsAt = fromAsAt;
    return this;
  }

   /**
   * The requested AsAt date for the resource (if null, Latest). If specifying a range of AsAt dates, this is the lower bounds.
   * @return fromAsAt
  **/
  @jakarta.annotation.Nullable
  public OffsetDateTime getFromAsAt() {
    return fromAsAt;
  }


  public void setFromAsAt(OffsetDateTime fromAsAt) {
    this.fromAsAt = fromAsAt;
  }


  public RequestDetails toAsAt(OffsetDateTime toAsAt) {
    
    this.toAsAt = toAsAt;
    return this;
  }

   /**
   * Upper bound if specifying a request that requires a range of AsAt dates. This is used if specifying the desire to grant access for a user between an AsAt range.
   * @return toAsAt
  **/
  @jakarta.annotation.Nullable
  public OffsetDateTime getToAsAt() {
    return toAsAt;
  }


  public void setToAsAt(OffsetDateTime toAsAt) {
    this.toAsAt = toAsAt;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    RequestDetails requestDetails = (RequestDetails) o;
    return Objects.equals(this.action, requestDetails.action) &&
        Objects.equals(this.fromEffectiveDate, requestDetails.fromEffectiveDate) &&
        Objects.equals(this.toEffectiveDate, requestDetails.toEffectiveDate) &&
        Objects.equals(this.fromAsAt, requestDetails.fromAsAt) &&
        Objects.equals(this.toAsAt, requestDetails.toAsAt);
  }

  private static  boolean equalsNullable(JsonNullable a, JsonNullable b) {
    return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
  }

  @Override
  public int hashCode() {
    return Objects.hash(action, fromEffectiveDate, toEffectiveDate, fromAsAt, toAsAt);
  }

  private static  int hashCodeNullable(JsonNullable a) {
    if (a == null) {
      return 1;
    }
    return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class RequestDetails {\n");
    sb.append("    action: ").append(toIndentedString(action)).append("\n");
    sb.append("    fromEffectiveDate: ").append(toIndentedString(fromEffectiveDate)).append("\n");
    sb.append("    toEffectiveDate: ").append(toIndentedString(toEffectiveDate)).append("\n");
    sb.append("    fromAsAt: ").append(toIndentedString(fromAsAt)).append("\n");
    sb.append("    toAsAt: ").append(toIndentedString(toAsAt)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }


  public static HashSet openapiFields;
  public static HashSet openapiRequiredFields;

  static {
    // a set of all properties/fields (JSON key names)
    openapiFields = new HashSet();
    openapiFields.add("action");
    openapiFields.add("fromEffectiveDate");
    openapiFields.add("toEffectiveDate");
    openapiFields.add("fromAsAt");
    openapiFields.add("toAsAt");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet();
    openapiRequiredFields.add("action");
  }

 /**
  * Validates the JSON Element and throws an exception if issues found
  *
  * @param jsonElement JSON Element
  * @throws IOException if the JSON Element is invalid with respect to RequestDetails
  */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!RequestDetails.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in RequestDetails is not found in the empty JSON string", RequestDetails.openapiRequiredFields.toString()));
        }
      }

      // check to make sure all required properties/fields are present in the JSON string
      for (String requiredField : RequestDetails.openapiRequiredFields) {
        if (jsonElement.getAsJsonObject().get(requiredField) == null) {
          throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      // validate the required field `action`
      RequestedActionKey.validateJsonElement(jsonObj.get("action"));
  }

  public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
    @SuppressWarnings("unchecked")
    @Override
    public  TypeAdapter create(Gson gson, TypeToken type) {
       if (!RequestDetails.class.isAssignableFrom(type.getRawType())) {
         return null; // this class only serializes 'RequestDetails' and its subtypes
       }
       final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
       final TypeAdapter thisAdapter
                        = gson.getDelegateAdapter(this, TypeToken.get(RequestDetails.class));

       return (TypeAdapter) new TypeAdapter() {
           @Override
           public void write(JsonWriter out, RequestDetails value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             elementAdapter.write(out, obj);
           }

           @Override
           public RequestDetails read(JsonReader in) throws IOException {
             JsonElement jsonElement = elementAdapter.read(in);
             validateJsonElement(jsonElement);
             return thisAdapter.fromJsonTree(jsonElement);
           }

       }.nullSafe();
    }
  }

 /**
  * Create an instance of RequestDetails given an JSON string
  *
  * @param jsonString JSON string
  * @return An instance of RequestDetails
  * @throws IOException if the JSON string is invalid with respect to RequestDetails
  */
  public static RequestDetails fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, RequestDetails.class);
  }

 /**
  * Convert an instance of RequestDetails to an JSON string
  *
  * @return JSON string
  */
  public String toJson() {
    return JSON.getGson().toJson(this);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy