/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

/*
 * ctrlX CORE - Data Layer API
 * This is the base API for the ctrlX Data Layer access on ctrlX CORE devices <ul> <li>Click 'Authorize' to open the 'Available authorizations' dialog.</li> <li>Enter 'username' and 'password'. The 'Client credentials location' selector together with the 'client_id' and 'client_secret' fields as well as the 'Bearer' section can be ignored.</li> <li>Click 'Authorize' and then 'Close' to close the 'Available authorizations' dialog.</li> <li>Try out those GET, PUT, ... operations you're interested in.</li> </ul>
 *
 * The version of the OpenAPI document: 2.1.0
 * Contact: support@boschrexroth.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package org.apache.plc4x.java.ctrlx.readwrite.rest.datalayer.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeName;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Objects;
import java.util.StringJoiner;

/**
 * ReflectionType
 */
@JsonPropertyOrder({
  ReflectionType.JSON_PROPERTY_BASE_TYPE,
  ReflectionType.JSON_PROPERTY_ELEMENT,
  ReflectionType.JSON_PROPERTY_INDEX
})
@JsonTypeName("reflection_Type")
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-11-18T13:34:36.056861+01:00[Europe/Berlin]")
public class ReflectionType {
  public static final String JSON_PROPERTY_BASE_TYPE = "base_type";
  private ReflectionBaseType baseType;

  public static final String JSON_PROPERTY_ELEMENT = "element";
  private ReflectionBaseType element;

  public static final String JSON_PROPERTY_INDEX = "index";
  private Integer index;

  public ReflectionType() {
  }

  public ReflectionType baseType(ReflectionBaseType baseType) {
    
    this.baseType = baseType;
    return this;
  }

   /**
   * Get baseType
   * @return baseType
  **/
  @jakarta.annotation.Nullable
  @JsonProperty(JSON_PROPERTY_BASE_TYPE)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

  public ReflectionBaseType getBaseType() {
    return baseType;
  }


  @JsonProperty(JSON_PROPERTY_BASE_TYPE)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
  public void setBaseType(ReflectionBaseType baseType) {
    this.baseType = baseType;
  }


  public ReflectionType element(ReflectionBaseType element) {
    
    this.element = element;
    return this;
  }

   /**
   * Get element
   * @return element
  **/
  @jakarta.annotation.Nullable
  @JsonProperty(JSON_PROPERTY_ELEMENT)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

  public ReflectionBaseType getElement() {
    return element;
  }


  @JsonProperty(JSON_PROPERTY_ELEMENT)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
  public void setElement(ReflectionBaseType element) {
    this.element = element;
  }


  public ReflectionType index(Integer index) {
    
    this.index = index;
    return this;
  }

   /**
   * Get index
   * minimum: -2147483648
   * maximum: 2147483647
   * @return index
  **/
  @jakarta.annotation.Nullable
  @JsonProperty(JSON_PROPERTY_INDEX)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

  public Integer getIndex() {
    return index;
  }


  @JsonProperty(JSON_PROPERTY_INDEX)
  @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
  public void setIndex(Integer index) {
    this.index = index;
  }


  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    ReflectionType reflectionType = (ReflectionType) o;
    return Objects.equals(this.baseType, reflectionType.baseType) &&
        Objects.equals(this.element, reflectionType.element) &&
        Objects.equals(this.index, reflectionType.index);
  }

  @Override
  public int hashCode() {
    return Objects.hash(baseType, element, index);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class ReflectionType {\n");
    sb.append("    baseType: ").append(toIndentedString(baseType)).append("\n");
    sb.append("    element: ").append(toIndentedString(element)).append("\n");
    sb.append("    index: ").append(toIndentedString(index)).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    ");
  }

  /**
   * Convert the instance into URL query string.
   *
   * @return URL query string
   */
  public String toUrlQueryString() {
    return toUrlQueryString(null);
  }

  /**
   * Convert the instance into URL query string.
   *
   * @param prefix prefix of the query string
   * @return URL query string
   */
  public String toUrlQueryString(String prefix) {
    String suffix = "";
    String containerSuffix = "";
    String containerPrefix = "";
    if (prefix == null) {
      // style=form, explode=true, e.g. /pet?name=cat&type=manx
      prefix = "";
    } else {
      // deepObject style e.g. /pet?id[name]=cat&id[type]=manx
      prefix = prefix + "[";
      suffix = "]";
      containerSuffix = "]";
      containerPrefix = "[";
    }

    StringJoiner joiner = new StringJoiner("&");

    // add `base_type` to the URL query string
    if (getBaseType() != null) {
      try {
        joiner.add(String.format("%sbase_type%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBaseType()), "UTF-8").replaceAll("\\+", "%20")));
      } catch (UnsupportedEncodingException e) {
        // Should never happen, UTF-8 is always supported
        throw new RuntimeException(e);
      }
    }

    // add `element` to the URL query string
    if (getElement() != null) {
      try {
        joiner.add(String.format("%selement%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getElement()), "UTF-8").replaceAll("\\+", "%20")));
      } catch (UnsupportedEncodingException e) {
        // Should never happen, UTF-8 is always supported
        throw new RuntimeException(e);
      }
    }

    // add `index` to the URL query string
    if (getIndex() != null) {
      try {
        joiner.add(String.format("%sindex%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getIndex()), "UTF-8").replaceAll("\\+", "%20")));
      } catch (UnsupportedEncodingException e) {
        // Should never happen, UTF-8 is always supported
        throw new RuntimeException(e);
      }
    }

    return joiner.toString();
  }

}

