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

org.cloudfoundry.client.v2.applications.Usage Maven / Gradle / Ivy

There is a newer version: 5.12.2.RELEASE
Show newest version
package org.cloudfoundry.client.v2.applications;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.Objects;
import org.cloudfoundry.Nullable;
import org.immutables.value.Generated;

/**
 * Application instance usage info
 */
@Generated(from = "_Usage", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class Usage extends org.cloudfoundry.client.v2.applications._Usage {
  private final @Nullable Double cpu;
  private final @Nullable Long disk;
  private final @Nullable Long memory;
  private final @Nullable String time;

  private Usage(Usage.Builder builder) {
    this.cpu = builder.cpu;
    this.disk = builder.disk;
    this.memory = builder.memory;
    this.time = builder.time;
  }

  /**
   * The CPU usage
   */
  @JsonProperty("cpu")
  @Override
  public @Nullable Double getCpu() {
    return cpu;
  }

  /**
   * The disk usage
   */
  @JsonProperty("disk")
  @Override
  public @Nullable Long getDisk() {
    return disk;
  }

  /**
   * The memory usage
   */
  @JsonProperty("mem")
  @Override
  public @Nullable Long getMemory() {
    return memory;
  }

  /**
   * The time since start
   */
  @JsonProperty("time")
  @Override
  public @Nullable String getTime() {
    return time;
  }

  /**
   * This instance is equal to all instances of {@code Usage} that have equal attribute values.
   * @return {@code true} if {@code this} is equal to {@code another} instance
   */
  @Override
  public boolean equals(Object another) {
    if (this == another) return true;
    return another instanceof Usage
        && equalTo(0, (Usage) another);
  }

  private boolean equalTo(int synthetic, Usage another) {
    return Objects.equals(cpu, another.cpu)
        && Objects.equals(disk, another.disk)
        && Objects.equals(memory, another.memory)
        && Objects.equals(time, another.time);
  }

  /**
   * Computes a hash code from attributes: {@code cpu}, {@code disk}, {@code memory}, {@code time}.
   * @return hashCode value
   */
  @Override
  public int hashCode() {
    int h = 5381;
    h += (h << 5) + Objects.hashCode(cpu);
    h += (h << 5) + Objects.hashCode(disk);
    h += (h << 5) + Objects.hashCode(memory);
    h += (h << 5) + Objects.hashCode(time);
    return h;
  }

  /**
   * Prints the immutable value {@code Usage} with attribute values.
   * @return A string representation of the value
   */
  @Override
  public String toString() {
    return "Usage{"
        + "cpu=" + cpu
        + ", disk=" + disk
        + ", memory=" + memory
        + ", time=" + time
        + "}";
  }

  /**
   * Utility type used to correctly read immutable object from JSON representation.
   * @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure
   */
  @Generated(from = "_Usage", generator = "Immutables")
  @Deprecated
  @JsonDeserialize
  @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
  static final class Json extends org.cloudfoundry.client.v2.applications._Usage {
    Double cpu;
    Long disk;
    Long memory;
    String time;
    @JsonProperty("cpu")
    public void setCpu(@Nullable Double cpu) {
      this.cpu = cpu;
    }
    @JsonProperty("disk")
    public void setDisk(@Nullable Long disk) {
      this.disk = disk;
    }
    @JsonProperty("mem")
    public void setMemory(@Nullable Long memory) {
      this.memory = memory;
    }
    @JsonProperty("time")
    public void setTime(@Nullable String time) {
      this.time = time;
    }
    @Override
    public Double getCpu() { throw new UnsupportedOperationException(); }
    @Override
    public Long getDisk() { throw new UnsupportedOperationException(); }
    @Override
    public Long getMemory() { throw new UnsupportedOperationException(); }
    @Override
    public String getTime() { throw new UnsupportedOperationException(); }
  }

  /**
   * @param json A JSON-bindable data structure
   * @return An immutable value type
   * @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure
   */
  @Deprecated
  @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
  static Usage fromJson(Json json) {
    Usage.Builder builder = Usage.builder();
    if (json.cpu != null) {
      builder.cpu(json.cpu);
    }
    if (json.disk != null) {
      builder.disk(json.disk);
    }
    if (json.memory != null) {
      builder.memory(json.memory);
    }
    if (json.time != null) {
      builder.time(json.time);
    }
    return builder.build();
  }

  /**
   * Creates a builder for {@link Usage Usage}.
   * 
   * Usage.builder()
   *    .cpu(Double | null) // nullable {@link Usage#getCpu() cpu}
   *    .disk(Long | null) // nullable {@link Usage#getDisk() disk}
   *    .memory(Long | null) // nullable {@link Usage#getMemory() memory}
   *    .time(String | null) // nullable {@link Usage#getTime() time}
   *    .build();
   * 
* @return A new Usage builder */ public static Usage.Builder builder() { return new Usage.Builder(); } /** * Builds instances of type {@link Usage Usage}. * Initialize attributes and then invoke the {@link #build()} method to create an * immutable instance. *

{@code Builder} is not thread-safe and generally should not be stored in a field or collection, * but instead used immediately to create instances. */ @Generated(from = "_Usage", generator = "Immutables") public static final class Builder { private Double cpu; private Long disk; private Long memory; private String time; private Builder() { } /** * Fill a builder with attribute values from the provided {@code Usage} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(Usage instance) { return from((_Usage) instance); } /** * Copy abstract value type {@code _Usage} instance into builder. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ final Builder from(_Usage instance) { Objects.requireNonNull(instance, "instance"); Double cpuValue = instance.getCpu(); if (cpuValue != null) { cpu(cpuValue); } Long diskValue = instance.getDisk(); if (diskValue != null) { disk(diskValue); } Long memoryValue = instance.getMemory(); if (memoryValue != null) { memory(memoryValue); } String timeValue = instance.getTime(); if (timeValue != null) { time(timeValue); } return this; } /** * Initializes the value for the {@link Usage#getCpu() cpu} attribute. * @param cpu The value for cpu (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("cpu") public final Builder cpu(@Nullable Double cpu) { this.cpu = cpu; return this; } /** * Initializes the value for the {@link Usage#getDisk() disk} attribute. * @param disk The value for disk (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("disk") public final Builder disk(@Nullable Long disk) { this.disk = disk; return this; } /** * Initializes the value for the {@link Usage#getMemory() memory} attribute. * @param memory The value for memory (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("mem") public final Builder memory(@Nullable Long memory) { this.memory = memory; return this; } /** * Initializes the value for the {@link Usage#getTime() time} attribute. * @param time The value for time (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("time") public final Builder time(@Nullable String time) { this.time = time; return this; } /** * Builds a new {@link Usage Usage}. * @return An immutable instance of Usage * @throws java.lang.IllegalStateException if any required attributes are missing */ public Usage build() { return new Usage(this); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy