![JAR search and dependency download from the Maven repository](/logo.png)
org.glowroot.instrumentation.engine.weaving.ImmutableLoadFromFileResult Maven / Gradle / Ivy
package org.glowroot.instrumentation.engine.weaving;
import org.glowroot.instrumentation.test.harness.shaded.com.google.common.base.MoreObjects;
import org.glowroot.instrumentation.test.harness.shaded.com.google.common.base.Preconditions;
import org.glowroot.instrumentation.test.harness.shaded.com.google.common.primitives.Booleans;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentMap;
import org.immutables.value.Generated;
/**
* Immutable implementation of {@link PreloadSomeSuperTypesCache.LoadFromFileResult}.
*
* Use the builder to create immutable instances:
* {@code ImmutableLoadFromFileResult.builder()}.
*/
@Generated(from = "PreloadSomeSuperTypesCache.LoadFromFileResult", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
final class ImmutableLoadFromFileResult
implements PreloadSomeSuperTypesCache.LoadFromFileResult {
private final ConcurrentMap cache;
private final int linesInFile;
private final boolean trackAccessTimes;
private ImmutableLoadFromFileResult(
ConcurrentMap cache,
int linesInFile,
boolean trackAccessTimes) {
this.cache = cache;
this.linesInFile = linesInFile;
this.trackAccessTimes = trackAccessTimes;
}
/**
* @return The value of the {@code cache} attribute
*/
@Override
public ConcurrentMap cache() {
return cache;
}
/**
* @return The value of the {@code linesInFile} attribute
*/
@Override
public int linesInFile() {
return linesInFile;
}
/**
* @return The value of the {@code trackAccessTimes} attribute
*/
@Override
public boolean trackAccessTimes() {
return trackAccessTimes;
}
/**
* Copy the current immutable object by setting a value for the {@link PreloadSomeSuperTypesCache.LoadFromFileResult#cache() cache} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for cache
* @return A modified copy of the {@code this} object
*/
public final ImmutableLoadFromFileResult withCache(ConcurrentMap value) {
if (this.cache == value) return this;
ConcurrentMap newValue = Preconditions.checkNotNull(value, "cache");
return new ImmutableLoadFromFileResult(newValue, this.linesInFile, this.trackAccessTimes);
}
/**
* Copy the current immutable object by setting a value for the {@link PreloadSomeSuperTypesCache.LoadFromFileResult#linesInFile() linesInFile} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for linesInFile
* @return A modified copy of the {@code this} object
*/
public final ImmutableLoadFromFileResult withLinesInFile(int value) {
if (this.linesInFile == value) return this;
return new ImmutableLoadFromFileResult(this.cache, value, this.trackAccessTimes);
}
/**
* Copy the current immutable object by setting a value for the {@link PreloadSomeSuperTypesCache.LoadFromFileResult#trackAccessTimes() trackAccessTimes} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for trackAccessTimes
* @return A modified copy of the {@code this} object
*/
public final ImmutableLoadFromFileResult withTrackAccessTimes(boolean value) {
if (this.trackAccessTimes == value) return this;
return new ImmutableLoadFromFileResult(this.cache, this.linesInFile, value);
}
/**
* This instance is equal to all instances of {@code ImmutableLoadFromFileResult} 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 ImmutableLoadFromFileResult
&& equalTo((ImmutableLoadFromFileResult) another);
}
private boolean equalTo(ImmutableLoadFromFileResult another) {
return cache.equals(another.cache)
&& linesInFile == another.linesInFile
&& trackAccessTimes == another.trackAccessTimes;
}
/**
* Computes a hash code from attributes: {@code cache}, {@code linesInFile}, {@code trackAccessTimes}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + cache.hashCode();
h += (h << 5) + linesInFile;
h += (h << 5) + Booleans.hashCode(trackAccessTimes);
return h;
}
/**
* Prints the immutable value {@code LoadFromFileResult} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("LoadFromFileResult")
.omitNullValues()
.add("cache", cache)
.add("linesInFile", linesInFile)
.add("trackAccessTimes", trackAccessTimes)
.toString();
}
/**
* Creates an immutable copy of a {@link PreloadSomeSuperTypesCache.LoadFromFileResult} value.
* Uses accessors to get values to initialize the new immutable instance.
* If an instance is already immutable, it is returned as is.
* @param instance The instance to copy
* @return A copied immutable LoadFromFileResult instance
*/
public static ImmutableLoadFromFileResult copyOf(PreloadSomeSuperTypesCache.LoadFromFileResult instance) {
if (instance instanceof ImmutableLoadFromFileResult) {
return (ImmutableLoadFromFileResult) instance;
}
return ImmutableLoadFromFileResult.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableLoadFromFileResult ImmutableLoadFromFileResult}.
*
* ImmutableLoadFromFileResult.builder()
* .cache(concurrent.ConcurrentMap<String, org.glowroot.instrumentation.engine.weaving.PreloadSomeSuperTypesCache.CacheValue>) // required {@link PreloadSomeSuperTypesCache.LoadFromFileResult#cache() cache}
* .linesInFile(int) // required {@link PreloadSomeSuperTypesCache.LoadFromFileResult#linesInFile() linesInFile}
* .trackAccessTimes(boolean) // required {@link PreloadSomeSuperTypesCache.LoadFromFileResult#trackAccessTimes() trackAccessTimes}
* .build();
*
* @return A new ImmutableLoadFromFileResult builder
*/
public static ImmutableLoadFromFileResult.Builder builder() {
return new ImmutableLoadFromFileResult.Builder();
}
/**
* Builds instances of type {@link ImmutableLoadFromFileResult ImmutableLoadFromFileResult}.
* 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 = "PreloadSomeSuperTypesCache.LoadFromFileResult", generator = "Immutables")
public static final class Builder {
private static final long INIT_BIT_CACHE = 0x1L;
private static final long INIT_BIT_LINES_IN_FILE = 0x2L;
private static final long INIT_BIT_TRACK_ACCESS_TIMES = 0x4L;
private long initBits = 0x7L;
private ConcurrentMap cache;
private int linesInFile;
private boolean trackAccessTimes;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code LoadFromFileResult} 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(PreloadSomeSuperTypesCache.LoadFromFileResult instance) {
Preconditions.checkNotNull(instance, "instance");
cache(instance.cache());
linesInFile(instance.linesInFile());
trackAccessTimes(instance.trackAccessTimes());
return this;
}
/**
* Initializes the value for the {@link PreloadSomeSuperTypesCache.LoadFromFileResult#cache() cache} attribute.
* @param cache The value for cache
* @return {@code this} builder for use in a chained invocation
*/
public final Builder cache(ConcurrentMap cache) {
this.cache = Preconditions.checkNotNull(cache, "cache");
initBits &= ~INIT_BIT_CACHE;
return this;
}
/**
* Initializes the value for the {@link PreloadSomeSuperTypesCache.LoadFromFileResult#linesInFile() linesInFile} attribute.
* @param linesInFile The value for linesInFile
* @return {@code this} builder for use in a chained invocation
*/
public final Builder linesInFile(int linesInFile) {
this.linesInFile = linesInFile;
initBits &= ~INIT_BIT_LINES_IN_FILE;
return this;
}
/**
* Initializes the value for the {@link PreloadSomeSuperTypesCache.LoadFromFileResult#trackAccessTimes() trackAccessTimes} attribute.
* @param trackAccessTimes The value for trackAccessTimes
* @return {@code this} builder for use in a chained invocation
*/
public final Builder trackAccessTimes(boolean trackAccessTimes) {
this.trackAccessTimes = trackAccessTimes;
initBits &= ~INIT_BIT_TRACK_ACCESS_TIMES;
return this;
}
/**
* Builds a new {@link ImmutableLoadFromFileResult ImmutableLoadFromFileResult}.
* @return An immutable instance of LoadFromFileResult
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableLoadFromFileResult build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableLoadFromFileResult(cache, linesInFile, trackAccessTimes);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList();
if ((initBits & INIT_BIT_CACHE) != 0) attributes.add("cache");
if ((initBits & INIT_BIT_LINES_IN_FILE) != 0) attributes.add("linesInFile");
if ((initBits & INIT_BIT_TRACK_ACCESS_TIMES) != 0) attributes.add("trackAccessTimes");
return "Cannot build LoadFromFileResult, some of required attributes are not set " + attributes;
}
}
}