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

org.glowroot.ui.ImmutableTraceExport Maven / Gradle / Ivy

There is a newer version: 0.9.28
Show newest version
package org.glowroot.ui;

import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonCreator;
import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonProperty;
import org.glowroot.agent.shaded.google.common.base.MoreObjects;
import org.glowroot.agent.shaded.google.common.base.Objects;
import org.glowroot.agent.shaded.google.common.base.Preconditions;
import org.glowroot.agent.shaded.google.common.collect.Lists;
import java.util.List;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;

/**
 * Immutable implementation of {@link TraceCommonService.TraceExport}.
 * 

* Use builder to create immutable instances: * {@code ImmutableTraceExport.builder()}. * Use static factory method to create immutable instances: * {@code ImmutableTraceExport.of()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "TraceCommonService.TraceExport"}) @Immutable final class ImmutableTraceExport implements TraceCommonService.TraceExport { private final String fileName; private final String headerJson; private final @Nullable String entriesJson; private final @Nullable String profileTreeJson; private ImmutableTraceExport( String fileName, String headerJson, @Nullable String entriesJson, @Nullable String profileTreeJson) { this.fileName = Preconditions.checkNotNull(fileName); this.headerJson = Preconditions.checkNotNull(headerJson); this.entriesJson = entriesJson; this.profileTreeJson = profileTreeJson; } private ImmutableTraceExport( ImmutableTraceExport original, String fileName, String headerJson, @Nullable String entriesJson, @Nullable String profileTreeJson) { this.fileName = fileName; this.headerJson = headerJson; this.entriesJson = entriesJson; this.profileTreeJson = profileTreeJson; } /** * @return value of {@code fileName} attribute */ @JsonProperty @Override public String fileName() { return fileName; } /** * @return value of {@code headerJson} attribute */ @JsonProperty @Override public String headerJson() { return headerJson; } /** * @return value of {@code entriesJson} attribute */ @JsonProperty @Override public @Nullable String entriesJson() { return entriesJson; } /** * @return value of {@code profileTreeJson} attribute */ @JsonProperty @Override public @Nullable String profileTreeJson() { return profileTreeJson; } /** * Copy current immutable object by setting value for {@link TraceCommonService.TraceExport#fileName() fileName}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for fileName * @return modified copy of the {@code this} object */ public final ImmutableTraceExport withFileName(String value) { if (this.fileName == value) return this; String newValue = Preconditions.checkNotNull(value); return new ImmutableTraceExport(this, newValue, this.headerJson, this.entriesJson, this.profileTreeJson); } /** * Copy current immutable object by setting value for {@link TraceCommonService.TraceExport#headerJson() headerJson}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for headerJson * @return modified copy of the {@code this} object */ public final ImmutableTraceExport withHeaderJson(String value) { if (this.headerJson == value) return this; String newValue = Preconditions.checkNotNull(value); return new ImmutableTraceExport(this, this.fileName, newValue, this.entriesJson, this.profileTreeJson); } /** * Copy current immutable object by setting value for {@link TraceCommonService.TraceExport#entriesJson() entriesJson}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for entriesJson, can be {@code null} * @return modified copy of the {@code this} object */ public final ImmutableTraceExport withEntriesJson(@Nullable String value) { if (this.entriesJson == value) return this; @Nullable String newValue = value; return new ImmutableTraceExport(this, this.fileName, this.headerJson, newValue, this.profileTreeJson); } /** * Copy current immutable object by setting value for {@link TraceCommonService.TraceExport#profileTreeJson() profileTreeJson}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for profileTreeJson, can be {@code null} * @return modified copy of the {@code this} object */ public final ImmutableTraceExport withProfileTreeJson(@Nullable String value) { if (this.profileTreeJson == value) return this; @Nullable String newValue = value; return new ImmutableTraceExport(this, this.fileName, this.headerJson, this.entriesJson, newValue); } /** * This instance is equal to instances of {@code ImmutableTraceExport} with equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { if (this == another) return true; return another instanceof ImmutableTraceExport && equalTo((ImmutableTraceExport) another); } private boolean equalTo(ImmutableTraceExport another) { return fileName.equals(another.fileName) && headerJson.equals(another.headerJson) && Objects.equal(entriesJson, another.entriesJson) && Objects.equal(profileTreeJson, another.profileTreeJson); } /** * Computes hash code from attributes: {@code fileName}, {@code headerJson}, {@code entriesJson}, {@code profileTreeJson}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + fileName.hashCode(); h = h * 17 + headerJson.hashCode(); h = h * 17 + Objects.hashCode(entriesJson); h = h * 17 + Objects.hashCode(profileTreeJson); return h; } /** * Prints immutable value {@code TraceExport...} with attribute values, * excluding any non-generated and auxiliary attributes. * @return string representation of value */ @Override public String toString() { return MoreObjects.toStringHelper("TraceExport") .add("fileName", fileName) .add("headerJson", headerJson) .add("entriesJson", entriesJson) .add("profileTreeJson", profileTreeJson) .toString(); } /** * Simple representation of this value type suitable Jackson binding * @deprecated Do not use this type directly, it exists only for Jackson-binding infrastructure */ @Deprecated static final class Json { @JsonProperty @Nullable String fileName; @JsonProperty @Nullable String headerJson; @JsonProperty @Nullable String entriesJson; @JsonProperty @Nullable String profileTreeJson; } /** * @param json JSON-bindable data structure * @return immutable value type * @deprecated Do not use this method directly, it exists only for Jackson-binding infrastructure */ @Deprecated @JsonCreator static ImmutableTraceExport fromJson(Json json) { ImmutableTraceExport.Builder builder = ImmutableTraceExport.builder(); if (json.fileName != null) { builder.fileName(json.fileName); } if (json.headerJson != null) { builder.headerJson(json.headerJson); } if (json.entriesJson != null) { builder.entriesJson(json.entriesJson); } if (json.profileTreeJson != null) { builder.profileTreeJson(json.profileTreeJson); } return builder.build(); } /** * Construct new immutable {@code TraceExport} instance. * @param fileName value for {@code fileName} * @param headerJson value for {@code headerJson} * @param entriesJson value for {@code entriesJson} * @param profileTreeJson value for {@code profileTreeJson} * @return immutable TraceExport instance */ public static ImmutableTraceExport of(String fileName, String headerJson, @Nullable String entriesJson, @Nullable String profileTreeJson) { return new ImmutableTraceExport(fileName, headerJson, entriesJson, profileTreeJson); } /** * Creates immutable copy of {@link TraceCommonService.TraceExport}. * Uses accessors to get values to initialize immutable instance. * If an instance is already immutable, it is returned as is. * @param instance instance to copy * @return copied immutable TraceExport instance */ static ImmutableTraceExport copyOf(TraceCommonService.TraceExport instance) { if (instance instanceof ImmutableTraceExport) { return (ImmutableTraceExport) instance; } return ImmutableTraceExport.builder() .copyFrom(instance) .build(); } /** * Creates builder for {@link org.glowroot.ui.ImmutableTraceExport ImmutableTraceExport}. * @return new ImmutableTraceExport builder */ static ImmutableTraceExport.Builder builder() { return new ImmutableTraceExport.Builder(); } /** * Builds instances of {@link org.glowroot.ui.ImmutableTraceExport ImmutableTraceExport}. * Initialize attributes and then invoke {@link #build()} method to create * immutable instance. *

{@code Builder} is not thread safe and generally should not be stored in field or collection, * but used immediately to create instances. */ @NotThreadSafe static final class Builder { private static final long INIT_BIT_FILE_NAME = 0x1L; private static final long INIT_BIT_HEADER_JSON = 0x2L; private long initBits = 0x3; private @Nullable String fileName; private @Nullable String headerJson; private @Nullable String entriesJson; private @Nullable String profileTreeJson; private Builder() {} /** * Fill builder with attribute values from provided {@link TraceCommonService.TraceExport} instance. * Regular attribute values will be replaced with ones of an instance. * Instance's absent optional values will not replace present values. * @param instance instance to copy values from * @return {@code this} builder for chained invocation */ public final Builder copyFrom(TraceCommonService.TraceExport instance) { Preconditions.checkNotNull(instance); fileName(instance.fileName()); headerJson(instance.headerJson()); @Nullable String entriesJsonValue = instance.entriesJson(); if (entriesJsonValue != null) { entriesJson(entriesJsonValue); } @Nullable String profileTreeJsonValue = instance.profileTreeJson(); if (profileTreeJsonValue != null) { profileTreeJson(profileTreeJsonValue); } return this; } /** * Initializes value for {@link TraceCommonService.TraceExport#fileName() fileName}. * @param fileName value for fileName * @return {@code this} builder for chained invocation */ public final Builder fileName(String fileName) { this.fileName = Preconditions.checkNotNull(fileName); initBits &= ~INIT_BIT_FILE_NAME; return this; } /** * Initializes value for {@link TraceCommonService.TraceExport#headerJson() headerJson}. * @param headerJson value for headerJson * @return {@code this} builder for chained invocation */ public final Builder headerJson(String headerJson) { this.headerJson = Preconditions.checkNotNull(headerJson); initBits &= ~INIT_BIT_HEADER_JSON; return this; } /** * Initializes value for {@link TraceCommonService.TraceExport#entriesJson() entriesJson}. * @param entriesJson value for entriesJson, can be {@code null} * @return {@code this} builder for chained invocation */ public final Builder entriesJson(@Nullable String entriesJson) { this.entriesJson = entriesJson; return this; } /** * Initializes value for {@link TraceCommonService.TraceExport#profileTreeJson() profileTreeJson}. * @param profileTreeJson value for profileTreeJson, can be {@code null} * @return {@code this} builder for chained invocation */ public final Builder profileTreeJson(@Nullable String profileTreeJson) { this.profileTreeJson = profileTreeJson; return this; } /** * Builds new {@link org.glowroot.ui.ImmutableTraceExport ImmutableTraceExport}. * @return immutable instance of TraceExport * @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing */ public ImmutableTraceExport build() throws IllegalStateException { checkRequiredAttributes(); return new ImmutableTraceExport(null, fileName, headerJson, entriesJson, profileTreeJson); } private boolean fileNameIsSet() { return (initBits & INIT_BIT_FILE_NAME) == 0; } private boolean headerJsonIsSet() { return (initBits & INIT_BIT_HEADER_JSON) == 0; } private void checkRequiredAttributes() throws IllegalStateException { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = Lists.newArrayList(); if (!fileNameIsSet()) attributes.add("fileName"); if (!headerJsonIsSet()) attributes.add("headerJson"); return "Cannot build TraceExport, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy