Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.facebook.buck.apple;
- import com.google.common.base.MoreObjects;
- import com.google.common.base.Preconditions;
- import java.nio.file.Path;
- 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 AppleSdkPaths}.
- * <p>
- * Use static factory methods to create instances: {@code of()} or
- * {@code builder()}.
- */
- @SuppressWarnings({"all", "unchecked"})
- @ParametersAreNonnullByDefault
- @Generated({"Immutables.generator", "AppleSdkPaths"})
- @Immutable
- public final class ImmutableAppleSdkPaths
- implements AppleSdkPaths {
- private static ImmutableAppleSdkPaths checkPreconditions(ImmutableAppleSdkPaths instance) {
- return instance;
- }
- /**
- * Creates immutable copy of AppleSdkPaths. Uses accessors to get values to initialize new immutable instance.
- * If instance is already immutable, it returns it unchanged.
- */
- public static ImmutableAppleSdkPaths copyOf(AppleSdkPaths instance) {
- if (instance instanceof ImmutableAppleSdkPaths) {
- return (ImmutableAppleSdkPaths) instance;
- }
- Preconditions.checkNotNull(instance);
- return builder()
- .toolchainPath(instance.toolchainPath())
- .platformDeveloperPath(instance.platformDeveloperPath())
- .sdkPath(instance.sdkPath())
- .build();
- }
- /**
- * @deprecated Already an immutable object, no need to create immutable copy
- */
- @Deprecated
- public static ImmutableAppleSdkPaths copyOf(ImmutableAppleSdkPaths instance) {
- return Preconditions.checkNotNull(instance);
- }
- private final Path toolchainPath;
- private final Path platformDeveloperPath;
- private final Path sdkPath;
- private ImmutableAppleSdkPaths(Builder builder) {
- this.toolchainPath = builder.toolchainPath;
- this.platformDeveloperPath = builder.platformDeveloperPath;
- this.sdkPath = builder.sdkPath;
- }
- private ImmutableAppleSdkPaths(
- ImmutableAppleSdkPaths copiedInstance,
- Path toolchainPath,
- Path platformDeveloperPath,
- Path sdkPath) {
- this.toolchainPath = toolchainPath;
- this.platformDeveloperPath = platformDeveloperPath;
- this.sdkPath = sdkPath;
- }
- /**
- * Copy current immutable object by setting value for {@link AppleSdkPaths#toolchainPath()}.
- * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
- * @param value value for toolchainPath, non-null
- * @return modified copy of the {@code this} object
- */
- public final ImmutableAppleSdkPaths withToolchainPath(Path value) {
- if (this.toolchainPath == value) {
- return this;
- }
- Path newValue = Preconditions.checkNotNull(value);
- return checkPreconditions(new ImmutableAppleSdkPaths(
- this,
- newValue,
- this.platformDeveloperPath,
- this.sdkPath));
- }
- /**
- * Copy current immutable object by setting value for {@link AppleSdkPaths#platformDeveloperPath()}.
- * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
- * @param value value for platformDeveloperPath, non-null
- * @return modified copy of the {@code this} object
- */
- public final ImmutableAppleSdkPaths withPlatformDeveloperPath(Path value) {
- if (this.platformDeveloperPath == value) {
- return this;
- }
- Path newValue = Preconditions.checkNotNull(value);
- return checkPreconditions(new ImmutableAppleSdkPaths(
- this,
- this.toolchainPath,
- newValue,
- this.sdkPath));
- }
- /**
- * Copy current immutable object by setting value for {@link AppleSdkPaths#sdkPath()}.
- * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
- * @param value value for sdkPath, non-null
- * @return modified copy of the {@code this} object
- */
- public final ImmutableAppleSdkPaths withSdkPath(Path value) {
- if (this.sdkPath == value) {
- return this;
- }
- Path newValue = Preconditions.checkNotNull(value);
- return checkPreconditions(new ImmutableAppleSdkPaths(
- this,
- this.toolchainPath,
- this.platformDeveloperPath,
- newValue));
- }
- @Override
- public Path toolchainPath() {
- return toolchainPath;
- }
- @Override
- public Path platformDeveloperPath() {
- return platformDeveloperPath;
- }
- @Override
- public Path sdkPath() {
- return sdkPath;
- }
- @Override
- public boolean equals(Object another) {
- return this == another
- || (another instanceof ImmutableAppleSdkPaths && equalTo((ImmutableAppleSdkPaths) another));
- }
- private boolean equalTo(ImmutableAppleSdkPaths another) {
- return toolchainPath.equals(another.toolchainPath)
- && platformDeveloperPath.equals(another.platformDeveloperPath)
- && sdkPath.equals(another.sdkPath);
- }
- private int computeHashCode() {
- int h = 31;
- h = h * 17 + toolchainPath.hashCode();
- h = h * 17 + platformDeveloperPath.hashCode();
- h = h * 17 + sdkPath.hashCode();
- return h;
- }
- @Override
- public int hashCode() {
- return computeHashCode();
- }
- @Override
- public String toString() {
- return MoreObjects.toStringHelper("AppleSdkPaths")
- .add("toolchainPath", toolchainPath)
- .add("platformDeveloperPath", platformDeveloperPath)
- .add("sdkPath", sdkPath)
- .toString();
- }
- /**
- * Creates builder for {@link AppleSdkPaths}.
- * @return new AppleSdkPaths builder
- */
- public static Builder builder() {
- return new Builder();
- }
- /**
- * Builds instances of {@link AppleSdkPaths}.
- * Builder is not thread safe and generally should not be stored in fields and collections,
- * but used immediately to create instances.
- */
- @NotThreadSafe
- public static final class Builder {
- private Builder() {
- }
- private long initializedBitset0;
- private static final long INITIALIZED_BITSET_ALL_0 = 0x7;
- private static final long INITIALIZED_BIT_TOOLCHAIN_PATH = 0x1L;
- private boolean toolchainPathIsSet() {
- return (initializedBitset0 & INITIALIZED_BIT_TOOLCHAIN_PATH) != 0;
- }
- private static final long INITIALIZED_BIT_PLATFORM_DEVELOPER_PATH = 0x2L;
- private boolean platformDeveloperPathIsSet() {
- return (initializedBitset0 & INITIALIZED_BIT_PLATFORM_DEVELOPER_PATH) != 0;
- }
- private static final long INITIALIZED_BIT_SDK_PATH = 0x4L;
- private boolean sdkPathIsSet() {
- return (initializedBitset0 & INITIALIZED_BIT_SDK_PATH) != 0;
- }
- @Nullable
- private Path toolchainPath;
- @Nullable
- private Path platformDeveloperPath;
- @Nullable
- private Path sdkPath;
- @Override
- public String toString() {
- return MoreObjects.toStringHelper("AppleSdkPaths.Builder")
- .omitNullValues()
- .add("toolchainPath", toolchainPath)
- .add("platformDeveloperPath", platformDeveloperPath)
- .add("sdkPath", sdkPath)
- .toString();
- }
- /**
- * Initializes value for {@link AppleSdkPaths#toolchainPath()}.
- * @param toolchainPath value for toolchainPath, non-null
- * @return {@code this} builder for chained invocation
- */
- public final Builder toolchainPath(Path toolchainPath) {
- this.toolchainPath = Preconditions.checkNotNull(toolchainPath);
- initializedBitset0 |= INITIALIZED_BIT_TOOLCHAIN_PATH;
- return this;
- }
- /**
- * Initializes value for {@link AppleSdkPaths#platformDeveloperPath()}.
- * @param platformDeveloperPath value for platformDeveloperPath, non-null
- * @return {@code this} builder for chained invocation
- */
- public final Builder platformDeveloperPath(Path platformDeveloperPath) {
- this.platformDeveloperPath = Preconditions.checkNotNull(platformDeveloperPath);
- initializedBitset0 |= INITIALIZED_BIT_PLATFORM_DEVELOPER_PATH;
- return this;
- }
- /**
- * Initializes value for {@link AppleSdkPaths#sdkPath()}.
- * @param sdkPath value for sdkPath, non-null
- * @return {@code this} builder for chained invocation
- */
- public final Builder sdkPath(Path sdkPath) {
- this.sdkPath = Preconditions.checkNotNull(sdkPath);
- initializedBitset0 |= INITIALIZED_BIT_SDK_PATH;
- return this;
- }
- private void checkRequiredAttributes() {
- if (initializedBitset0 != INITIALIZED_BITSET_ALL_0) {
- throw new IllegalStateException(
- MoreObjects.toStringHelper("Cannot build AppleSdkPaths, some of required attributes are not set ")
- .omitNullValues()
- .addValue(!toolchainPathIsSet() ? "toolchainPath" : null)
- .addValue(!platformDeveloperPathIsSet() ? "platformDeveloperPath" : null)
- .addValue(!sdkPathIsSet() ? "sdkPath" : null)
- .toString());
- }
- }
- /**
- * Builds new {@link AppleSdkPaths}.
- * @return immutable instance of AppleSdkPaths
- */
- public ImmutableAppleSdkPaths build() {
- checkRequiredAttributes();
- return checkPreconditions(new ImmutableAppleSdkPaths(this));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement