de.hilling.junit.cdi.scope.ImmutableTestScoped Maven / Gradle / Ivy
package de.hilling.junit.cdi.scope;
import java.lang.annotation.Annotation;
import java.util.Objects;
import org.immutables.value.Generated;
/**
* Immutable implementation of {@link TestScoped}.
*
* Use the builder to create immutable instances:
* {@code ImmutableTestScoped.builder()}.
*/
@Generated(from = "TestScoped", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableTestScoped implements TestScoped {
private ImmutableTestScoped(ImmutableTestScoped.Builder builder) {
}
/** {@inheritDoc} */
@Override
public Class extends Annotation> annotationType() {
return TestScoped.class;
}
/**
* This instance is equal to any implementation of the {@link ImmutableTestScoped} type with 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 TestScoped
&& equalTo(0, (TestScoped) another);
}
@SuppressWarnings("MethodCanBeStatic")
private boolean equalTo(int synthetic, TestScoped another) {
return true;
}
/**
* Returns a constant hash code value.
* @return hashCode value
*/
@Override
public int hashCode() {
return 533143163;
}
/**
* Prints the immutable value {@code TestScoped}.
* @return A string representation of the value
*/
@Override
public String toString() {
return "@TestScoped";
}
/**
* Creates an immutable copy of a {@link TestScoped} 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 TestScoped instance
*/
public static ImmutableTestScoped copyOf(TestScoped instance) {
if (instance instanceof ImmutableTestScoped) {
return (ImmutableTestScoped) instance;
}
return ImmutableTestScoped.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableTestScoped ImmutableTestScoped}.
*
* ImmutableTestScoped.builder()
* .build();
*
* @return A new ImmutableTestScoped builder
*/
public static ImmutableTestScoped.Builder builder() {
return new ImmutableTestScoped.Builder();
}
/**
* Builds instances of type {@link ImmutableTestScoped ImmutableTestScoped}.
* 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 = "TestScoped", generator = "Immutables")
public static final class Builder {
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code TestScoped} 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(TestScoped instance) {
Objects.requireNonNull(instance, "instance");
return this;
}
/**
* Builds a new {@link ImmutableTestScoped ImmutableTestScoped}.
* @return An immutable instance of TestScoped
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableTestScoped build() {
return new ImmutableTestScoped(this);
}
}
}