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

org.cloudfoundry.client.v3.processes.ProcessResource Maven / Gradle / Ivy

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

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.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.cloudfoundry.Nullable;
import org.cloudfoundry.client.v3.*;
import org.cloudfoundry.client.v3.Metadata;
import org.cloudfoundry.client.v3.Resource;
import org.immutables.value.Generated;

/**
 * The Resource response payload for the List processes operation
 */
@Generated(from = "_ProcessResource", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class ProcessResource extends org.cloudfoundry.client.v3.processes._ProcessResource {
  private final String createdAt;
  private final String id;
  private final Map links;
  private final @Nullable String updatedAt;
  private final String command;
  private final Integer diskInMb;
  private final HealthCheck healthCheck;
  private final Integer instances;
  private final Integer memoryInMb;
  private final Metadata metadata;
  private final ProcessRelationships relationships;
  private final String type;

  private ProcessResource(ProcessResource.Builder builder) {
    this.createdAt = builder.createdAt;
    this.id = builder.id;
    this.links = createUnmodifiableMap(false, false, builder.links);
    this.updatedAt = builder.updatedAt;
    this.command = builder.command;
    this.diskInMb = builder.diskInMb;
    this.healthCheck = builder.healthCheck;
    this.instances = builder.instances;
    this.memoryInMb = builder.memoryInMb;
    this.metadata = builder.metadata;
    this.relationships = builder.relationships;
    this.type = builder.type;
  }

  /**
   * When the resource was created
   */
  @JsonProperty("created_at")
  @Override
  public String getCreatedAt() {
    return createdAt;
  }

  /**
   * The resource's id
   */
  @JsonProperty("guid")
  @Override
  public String getId() {
    return id;
  }

  /**
   * Links to related resources and actions for the resource
   */
  @JsonProperty("links")
  @Override
  public Map getLinks() {
    return links;
  }

  /**
   * When the resource was last updated
   */
  @JsonProperty("updated_at")
  @Override
  public @Nullable String getUpdatedAt() {
    return updatedAt;
  }

  /**
   * The command
   */
  @JsonProperty("command")
  @Override
  public String getCommand() {
    return command;
  }

  /**
   * The disk in megabytes
   */
  @JsonProperty("disk_in_mb")
  @Override
  public Integer getDiskInMb() {
    return diskInMb;
  }

  /**
   * The health check
   */
  @JsonProperty("health_check")
  @Override
  public HealthCheck getHealthCheck() {
    return healthCheck;
  }

  /**
   * The instances
   */
  @JsonProperty("instances")
  @Override
  public Integer getInstances() {
    return instances;
  }

  /**
   * The memory in megabytes
   */
  @JsonProperty("memory_in_mb")
  @Override
  public Integer getMemoryInMb() {
    return memoryInMb;
  }

  /**
   * The metadata
   */
  @JsonProperty("metadata")
  @Override
  public Metadata getMetadata() {
    return metadata;
  }

  /**
   * The relationships
   */
  @JsonProperty("relationships")
  @Override
  public ProcessRelationships getRelationships() {
    return relationships;
  }

  /**
   * The type
   */
  @JsonProperty("type")
  @Override
  public String getType() {
    return type;
  }

  /**
   * This instance is equal to all instances of {@code ProcessResource} 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 ProcessResource
        && equalTo(0, (ProcessResource) another);
  }

  private boolean equalTo(int synthetic, ProcessResource another) {
    return createdAt.equals(another.createdAt)
        && id.equals(another.id)
        && links.equals(another.links)
        && Objects.equals(updatedAt, another.updatedAt)
        && command.equals(another.command)
        && diskInMb.equals(another.diskInMb)
        && healthCheck.equals(another.healthCheck)
        && instances.equals(another.instances)
        && memoryInMb.equals(another.memoryInMb)
        && metadata.equals(another.metadata)
        && relationships.equals(another.relationships)
        && type.equals(another.type);
  }

  /**
   * Computes a hash code from attributes: {@code createdAt}, {@code id}, {@code links}, {@code updatedAt}, {@code command}, {@code diskInMb}, {@code healthCheck}, {@code instances}, {@code memoryInMb}, {@code metadata}, {@code relationships}, {@code type}.
   * @return hashCode value
   */
  @Override
  public int hashCode() {
    int h = 5381;
    h += (h << 5) + createdAt.hashCode();
    h += (h << 5) + id.hashCode();
    h += (h << 5) + links.hashCode();
    h += (h << 5) + Objects.hashCode(updatedAt);
    h += (h << 5) + command.hashCode();
    h += (h << 5) + diskInMb.hashCode();
    h += (h << 5) + healthCheck.hashCode();
    h += (h << 5) + instances.hashCode();
    h += (h << 5) + memoryInMb.hashCode();
    h += (h << 5) + metadata.hashCode();
    h += (h << 5) + relationships.hashCode();
    h += (h << 5) + type.hashCode();
    return h;
  }

  /**
   * Prints the immutable value {@code ProcessResource} with attribute values.
   * @return A string representation of the value
   */
  @Override
  public String toString() {
    return "ProcessResource{"
        + "createdAt=" + createdAt
        + ", id=" + id
        + ", links=" + links
        + ", updatedAt=" + updatedAt
        + ", command=" + command
        + ", diskInMb=" + diskInMb
        + ", healthCheck=" + healthCheck
        + ", instances=" + instances
        + ", memoryInMb=" + memoryInMb
        + ", metadata=" + metadata
        + ", relationships=" + relationships
        + ", type=" + type
        + "}";
  }

  /**
   * 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 = "_ProcessResource", generator = "Immutables")
  @Deprecated
  @JsonDeserialize
  @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
  static final class Json extends org.cloudfoundry.client.v3.processes._ProcessResource {
    String createdAt;
    String id;
    Map links = Collections.emptyMap();
    String updatedAt;
    String command;
    Integer diskInMb;
    HealthCheck healthCheck;
    Integer instances;
    Integer memoryInMb;
    Metadata metadata;
    ProcessRelationships relationships;
    String type;
    @JsonProperty("created_at")
    public void setCreatedAt(String createdAt) {
      this.createdAt = createdAt;
    }
    @JsonProperty("guid")
    public void setId(String id) {
      this.id = id;
    }
    @JsonProperty("links")
    public void setLinks(Map links) {
      this.links = links;
    }
    @JsonProperty("updated_at")
    public void setUpdatedAt(@Nullable String updatedAt) {
      this.updatedAt = updatedAt;
    }
    @JsonProperty("command")
    public void setCommand(String command) {
      this.command = command;
    }
    @JsonProperty("disk_in_mb")
    public void setDiskInMb(Integer diskInMb) {
      this.diskInMb = diskInMb;
    }
    @JsonProperty("health_check")
    public void setHealthCheck(HealthCheck healthCheck) {
      this.healthCheck = healthCheck;
    }
    @JsonProperty("instances")
    public void setInstances(Integer instances) {
      this.instances = instances;
    }
    @JsonProperty("memory_in_mb")
    public void setMemoryInMb(Integer memoryInMb) {
      this.memoryInMb = memoryInMb;
    }
    @JsonProperty("metadata")
    public void setMetadata(Metadata metadata) {
      this.metadata = metadata;
    }
    @JsonProperty("relationships")
    public void setRelationships(ProcessRelationships relationships) {
      this.relationships = relationships;
    }
    @JsonProperty("type")
    public void setType(String type) {
      this.type = type;
    }
    @Override
    public String getCreatedAt() { throw new UnsupportedOperationException(); }
    @Override
    public String getId() { throw new UnsupportedOperationException(); }
    @Override
    public Map getLinks() { throw new UnsupportedOperationException(); }
    @Override
    public String getUpdatedAt() { throw new UnsupportedOperationException(); }
    @Override
    public String getCommand() { throw new UnsupportedOperationException(); }
    @Override
    public Integer getDiskInMb() { throw new UnsupportedOperationException(); }
    @Override
    public HealthCheck getHealthCheck() { throw new UnsupportedOperationException(); }
    @Override
    public Integer getInstances() { throw new UnsupportedOperationException(); }
    @Override
    public Integer getMemoryInMb() { throw new UnsupportedOperationException(); }
    @Override
    public Metadata getMetadata() { throw new UnsupportedOperationException(); }
    @Override
    public ProcessRelationships getRelationships() { throw new UnsupportedOperationException(); }
    @Override
    public String getType() { 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 ProcessResource fromJson(Json json) {
    ProcessResource.Builder builder = ProcessResource.builder();
    if (json.createdAt != null) {
      builder.createdAt(json.createdAt);
    }
    if (json.id != null) {
      builder.id(json.id);
    }
    if (json.links != null) {
      builder.putAllLinks(json.links);
    }
    if (json.updatedAt != null) {
      builder.updatedAt(json.updatedAt);
    }
    if (json.command != null) {
      builder.command(json.command);
    }
    if (json.diskInMb != null) {
      builder.diskInMb(json.diskInMb);
    }
    if (json.healthCheck != null) {
      builder.healthCheck(json.healthCheck);
    }
    if (json.instances != null) {
      builder.instances(json.instances);
    }
    if (json.memoryInMb != null) {
      builder.memoryInMb(json.memoryInMb);
    }
    if (json.metadata != null) {
      builder.metadata(json.metadata);
    }
    if (json.relationships != null) {
      builder.relationships(json.relationships);
    }
    if (json.type != null) {
      builder.type(json.type);
    }
    return builder.build();
  }

  /**
   * Creates a builder for {@link ProcessResource ProcessResource}.
   * 
   * ProcessResource.builder()
   *    .createdAt(String) // required {@link ProcessResource#getCreatedAt() createdAt}
   *    .id(String) // required {@link ProcessResource#getId() id}
   *    .link|putAllLinks(String => Link) // {@link ProcessResource#getLinks() links} mappings
   *    .updatedAt(String | null) // nullable {@link ProcessResource#getUpdatedAt() updatedAt}
   *    .command(String) // required {@link ProcessResource#getCommand() command}
   *    .diskInMb(Integer) // required {@link ProcessResource#getDiskInMb() diskInMb}
   *    .healthCheck(org.cloudfoundry.client.v3.processes.HealthCheck) // required {@link ProcessResource#getHealthCheck() healthCheck}
   *    .instances(Integer) // required {@link ProcessResource#getInstances() instances}
   *    .memoryInMb(Integer) // required {@link ProcessResource#getMemoryInMb() memoryInMb}
   *    .metadata(org.cloudfoundry.client.v3.Metadata) // required {@link ProcessResource#getMetadata() metadata}
   *    .relationships(org.cloudfoundry.client.v3.processes.ProcessRelationships) // required {@link ProcessResource#getRelationships() relationships}
   *    .type(String) // required {@link ProcessResource#getType() type}
   *    .build();
   * 
* @return A new ProcessResource builder */ public static ProcessResource.Builder builder() { return new ProcessResource.Builder(); } /** * Builds instances of type {@link ProcessResource ProcessResource}. * 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 = "_ProcessResource", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_CREATED_AT = 0x1L; private static final long INIT_BIT_ID = 0x2L; private static final long INIT_BIT_COMMAND = 0x4L; private static final long INIT_BIT_DISK_IN_MB = 0x8L; private static final long INIT_BIT_HEALTH_CHECK = 0x10L; private static final long INIT_BIT_INSTANCES = 0x20L; private static final long INIT_BIT_MEMORY_IN_MB = 0x40L; private static final long INIT_BIT_METADATA = 0x80L; private static final long INIT_BIT_RELATIONSHIPS = 0x100L; private static final long INIT_BIT_TYPE = 0x200L; private long initBits = 0x3ffL; private String createdAt; private String id; private Map links = new LinkedHashMap(); private String updatedAt; private String command; private Integer diskInMb; private HealthCheck healthCheck; private Integer instances; private Integer memoryInMb; private Metadata metadata; private ProcessRelationships relationships; private String type; private Builder() { } /** * Fill a builder with attribute values from the provided {@code org.cloudfoundry.client.v3.processes.Process} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(Process instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code org.cloudfoundry.client.v3.Resource} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(Resource instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code ProcessResource} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ProcessResource instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Copy abstract value type {@code _ProcessResource} instance into builder. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(_ProcessResource instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { long bits = 0; if (object instanceof Process) { Process instance = (Process) object; if ((bits & 0x10L) == 0) { diskInMb(instance.getDiskInMb()); bits |= 0x10L; } if ((bits & 0x20L) == 0) { createdAt(instance.getCreatedAt()); bits |= 0x20L; } if ((bits & 0x40L) == 0) { relationships(instance.getRelationships()); bits |= 0x40L; } if ((bits & 0x1L) == 0) { metadata(instance.getMetadata()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { instances(instance.getInstances()); bits |= 0x2L; } if ((bits & 0x80L) == 0) { memoryInMb(instance.getMemoryInMb()); bits |= 0x80L; } if ((bits & 0x100L) == 0) { healthCheck(instance.getHealthCheck()); bits |= 0x100L; } if ((bits & 0x200L) == 0) { putAllLinks(instance.getLinks()); bits |= 0x200L; } if ((bits & 0x400L) == 0) { id(instance.getId()); bits |= 0x400L; } if ((bits & 0x4L) == 0) { type(instance.getType()); bits |= 0x4L; } if ((bits & 0x8L) == 0) { command(instance.getCommand()); bits |= 0x8L; } if ((bits & 0x800L) == 0) { String updatedAtValue = instance.getUpdatedAt(); if (updatedAtValue != null) { updatedAt(updatedAtValue); } bits |= 0x800L; } } if (object instanceof Resource) { Resource instance = (Resource) object; if ((bits & 0x20L) == 0) { createdAt(instance.getCreatedAt()); bits |= 0x20L; } if ((bits & 0x200L) == 0) { putAllLinks(instance.getLinks()); bits |= 0x200L; } if ((bits & 0x400L) == 0) { id(instance.getId()); bits |= 0x400L; } if ((bits & 0x800L) == 0) { String updatedAtValue = instance.getUpdatedAt(); if (updatedAtValue != null) { updatedAt(updatedAtValue); } bits |= 0x800L; } } if (object instanceof org.cloudfoundry.client.v3.processes._ProcessResource) { org.cloudfoundry.client.v3.processes._ProcessResource instance = (org.cloudfoundry.client.v3.processes._ProcessResource) object; if ((bits & 0x10L) == 0) { diskInMb(instance.getDiskInMb()); bits |= 0x10L; } if ((bits & 0x40L) == 0) { relationships(instance.getRelationships()); bits |= 0x40L; } if ((bits & 0x1L) == 0) { metadata(instance.getMetadata()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { instances(instance.getInstances()); bits |= 0x2L; } if ((bits & 0x80L) == 0) { memoryInMb(instance.getMemoryInMb()); bits |= 0x80L; } if ((bits & 0x100L) == 0) { healthCheck(instance.getHealthCheck()); bits |= 0x100L; } if ((bits & 0x4L) == 0) { type(instance.getType()); bits |= 0x4L; } if ((bits & 0x8L) == 0) { command(instance.getCommand()); bits |= 0x8L; } } } /** * Initializes the value for the {@link ProcessResource#getCreatedAt() createdAt} attribute. * @param createdAt The value for createdAt * @return {@code this} builder for use in a chained invocation */ @JsonProperty("created_at") public final Builder createdAt(String createdAt) { this.createdAt = Objects.requireNonNull(createdAt, "createdAt"); initBits &= ~INIT_BIT_CREATED_AT; return this; } /** * Initializes the value for the {@link ProcessResource#getId() id} attribute. * @param id The value for id * @return {@code this} builder for use in a chained invocation */ @JsonProperty("guid") public final Builder id(String id) { this.id = Objects.requireNonNull(id, "id"); initBits &= ~INIT_BIT_ID; return this; } /** * Put one entry to the {@link ProcessResource#getLinks() links} map. * @param key The key in the links map * @param value The associated value in the links map * @return {@code this} builder for use in a chained invocation */ public final Builder link(String key, Link value) { this.links.put(key, value); return this; } /** * Put one entry to the {@link ProcessResource#getLinks() links} map. Nulls are not permitted * @param entry The key and value entry * @return {@code this} builder for use in a chained invocation */ public final Builder link(Map.Entry entry) { String k = entry.getKey(); Link v = entry.getValue(); this.links.put(k, v); return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link ProcessResource#getLinks() links} map. Nulls are not permitted * @param entries The entries that will be added to the links map * @return {@code this} builder for use in a chained invocation */ @JsonProperty("links") public final Builder links(Map entries) { this.links.clear(); return putAllLinks(entries); } /** * Put all mappings from the specified map as entries to {@link ProcessResource#getLinks() links} map. Nulls are not permitted * @param entries The entries that will be added to the links map * @return {@code this} builder for use in a chained invocation */ public final Builder putAllLinks(Map entries) { for (Map.Entry e : entries.entrySet()) { String k = e.getKey(); Link v = e.getValue(); this.links.put(k, v); } return this; } /** * Initializes the value for the {@link ProcessResource#getUpdatedAt() updatedAt} attribute. * @param updatedAt The value for updatedAt (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("updated_at") public final Builder updatedAt(@Nullable String updatedAt) { this.updatedAt = updatedAt; return this; } /** * Initializes the value for the {@link ProcessResource#getCommand() command} attribute. * @param command The value for command * @return {@code this} builder for use in a chained invocation */ @JsonProperty("command") public final Builder command(String command) { this.command = Objects.requireNonNull(command, "command"); initBits &= ~INIT_BIT_COMMAND; return this; } /** * Initializes the value for the {@link ProcessResource#getDiskInMb() diskInMb} attribute. * @param diskInMb The value for diskInMb * @return {@code this} builder for use in a chained invocation */ @JsonProperty("disk_in_mb") public final Builder diskInMb(Integer diskInMb) { this.diskInMb = Objects.requireNonNull(diskInMb, "diskInMb"); initBits &= ~INIT_BIT_DISK_IN_MB; return this; } /** * Initializes the value for the {@link ProcessResource#getHealthCheck() healthCheck} attribute. * @param healthCheck The value for healthCheck * @return {@code this} builder for use in a chained invocation */ @JsonProperty("health_check") public final Builder healthCheck(HealthCheck healthCheck) { this.healthCheck = Objects.requireNonNull(healthCheck, "healthCheck"); initBits &= ~INIT_BIT_HEALTH_CHECK; return this; } /** * Initializes the value for the {@link ProcessResource#getInstances() instances} attribute. * @param instances The value for instances * @return {@code this} builder for use in a chained invocation */ @JsonProperty("instances") public final Builder instances(Integer instances) { this.instances = Objects.requireNonNull(instances, "instances"); initBits &= ~INIT_BIT_INSTANCES; return this; } /** * Initializes the value for the {@link ProcessResource#getMemoryInMb() memoryInMb} attribute. * @param memoryInMb The value for memoryInMb * @return {@code this} builder for use in a chained invocation */ @JsonProperty("memory_in_mb") public final Builder memoryInMb(Integer memoryInMb) { this.memoryInMb = Objects.requireNonNull(memoryInMb, "memoryInMb"); initBits &= ~INIT_BIT_MEMORY_IN_MB; return this; } /** * Initializes the value for the {@link ProcessResource#getMetadata() metadata} attribute. * @param metadata The value for metadata * @return {@code this} builder for use in a chained invocation */ @JsonProperty("metadata") public final Builder metadata(Metadata metadata) { this.metadata = Objects.requireNonNull(metadata, "metadata"); initBits &= ~INIT_BIT_METADATA; return this; } /** * Initializes the value for the {@link ProcessResource#getRelationships() relationships} attribute. * @param relationships The value for relationships * @return {@code this} builder for use in a chained invocation */ @JsonProperty("relationships") public final Builder relationships(ProcessRelationships relationships) { this.relationships = Objects.requireNonNull(relationships, "relationships"); initBits &= ~INIT_BIT_RELATIONSHIPS; return this; } /** * Initializes the value for the {@link ProcessResource#getType() type} attribute. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ @JsonProperty("type") public final Builder type(String type) { this.type = Objects.requireNonNull(type, "type"); initBits &= ~INIT_BIT_TYPE; return this; } /** * Builds a new {@link ProcessResource ProcessResource}. * @return An immutable instance of ProcessResource * @throws java.lang.IllegalStateException if any required attributes are missing */ public ProcessResource build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ProcessResource(this); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_CREATED_AT) != 0) attributes.add("createdAt"); if ((initBits & INIT_BIT_ID) != 0) attributes.add("id"); if ((initBits & INIT_BIT_COMMAND) != 0) attributes.add("command"); if ((initBits & INIT_BIT_DISK_IN_MB) != 0) attributes.add("diskInMb"); if ((initBits & INIT_BIT_HEALTH_CHECK) != 0) attributes.add("healthCheck"); if ((initBits & INIT_BIT_INSTANCES) != 0) attributes.add("instances"); if ((initBits & INIT_BIT_MEMORY_IN_MB) != 0) attributes.add("memoryInMb"); if ((initBits & INIT_BIT_METADATA) != 0) attributes.add("metadata"); if ((initBits & INIT_BIT_RELATIONSHIPS) != 0) attributes.add("relationships"); if ((initBits & INIT_BIT_TYPE) != 0) attributes.add("type"); return "Cannot build ProcessResource, some of required attributes are not set " + attributes; } } private static Map createUnmodifiableMap(boolean checkNulls, boolean skipNulls, Map map) { switch (map.size()) { case 0: return Collections.emptyMap(); case 1: { Map.Entry e = map.entrySet().iterator().next(); K k = e.getKey(); V v = e.getValue(); if (checkNulls) { Objects.requireNonNull(k, "key"); Objects.requireNonNull(v, v == null ? "value for key: " + k : null); } if (skipNulls && (k == null || v == null)) { return Collections.emptyMap(); } return Collections.singletonMap(k, v); } default: { Map linkedMap = new LinkedHashMap<>(map.size() * 4 / 3 + 1); if (skipNulls || checkNulls) { for (Map.Entry e : map.entrySet()) { K k = e.getKey(); V v = e.getValue(); if (skipNulls) { if (k == null || v == null) continue; } else if (checkNulls) { Objects.requireNonNull(k, "key"); Objects.requireNonNull(v, v == null ? "value for key: " + k : null); } linkedMap.put(k, v); } } else { linkedMap.putAll(map); } return Collections.unmodifiableMap(linkedMap); } } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy