Advertisement
beng

Generated File for Immutables 1.0 issue

Oct 31st, 2014
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.27 KB | None | 0 0
  1. package com.facebook.buck.apple;
  2. import com.google.common.base.MoreObjects;
  3. import com.google.common.base.Preconditions;
  4. import java.nio.file.Path;
  5. import javax.annotation.Generated;
  6. import javax.annotation.Nullable;
  7. import javax.annotation.ParametersAreNonnullByDefault;
  8. import javax.annotation.concurrent.Immutable;
  9. import javax.annotation.concurrent.NotThreadSafe;
  10.  
  11.  
  12. /**
  13.  * Immutable implementation of {@link AppleSdkPaths}.
  14.  * <p>
  15.  * Use static factory methods to create instances: {@code of()} or
  16.  * {@code builder()}.
  17.  */
  18. @SuppressWarnings({"all", "unchecked"})
  19. @ParametersAreNonnullByDefault
  20. @Generated({"Immutables.generator", "AppleSdkPaths"})
  21. @Immutable
  22. public final class ImmutableAppleSdkPaths
  23.     implements AppleSdkPaths {
  24.  
  25.   private static ImmutableAppleSdkPaths checkPreconditions(ImmutableAppleSdkPaths instance) {
  26.     return instance;
  27.   }
  28.  
  29.   /**
  30.    * Creates immutable copy of AppleSdkPaths. Uses accessors to get values to initialize new immutable instance.
  31.    * If instance is already immutable, it returns it unchanged.
  32.    */
  33.   public static ImmutableAppleSdkPaths copyOf(AppleSdkPaths instance) {
  34.     if (instance instanceof ImmutableAppleSdkPaths) {
  35.       return (ImmutableAppleSdkPaths) instance;
  36.     }
  37.     Preconditions.checkNotNull(instance);
  38.     return builder()
  39.         .toolchainPath(instance.toolchainPath())
  40.         .platformDeveloperPath(instance.platformDeveloperPath())
  41.         .sdkPath(instance.sdkPath())
  42.         .build();
  43.   }
  44.  
  45.   /**
  46.    * @deprecated Already an immutable object, no need to create immutable copy
  47.    */
  48.   @Deprecated
  49.   public static ImmutableAppleSdkPaths copyOf(ImmutableAppleSdkPaths instance) {
  50.     return Preconditions.checkNotNull(instance);
  51.   }
  52.   private final Path toolchainPath;
  53.   private final Path platformDeveloperPath;
  54.   private final Path sdkPath;
  55.  
  56.   private ImmutableAppleSdkPaths(Builder builder) {
  57.     this.toolchainPath = builder.toolchainPath;
  58.     this.platformDeveloperPath = builder.platformDeveloperPath;
  59.     this.sdkPath = builder.sdkPath;
  60.   }
  61.  
  62.   private ImmutableAppleSdkPaths(
  63.       ImmutableAppleSdkPaths copiedInstance,
  64.       Path toolchainPath,
  65.       Path platformDeveloperPath,
  66.       Path sdkPath) {
  67.     this.toolchainPath = toolchainPath;
  68.     this.platformDeveloperPath = platformDeveloperPath;
  69.     this.sdkPath = sdkPath;
  70.   }
  71.  
  72.   /**
  73.    * Copy current immutable object by setting value for {@link AppleSdkPaths#toolchainPath()}.
  74.    * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
  75.    * @param value value for toolchainPath, non-null
  76.    * @return modified copy of the {@code this} object
  77.    */
  78.   public final ImmutableAppleSdkPaths withToolchainPath(Path value) {
  79.     if (this.toolchainPath == value) {
  80.       return this;
  81.     }
  82.     Path newValue = Preconditions.checkNotNull(value);
  83.     return checkPreconditions(new ImmutableAppleSdkPaths(
  84.         this,
  85.         newValue,
  86.         this.platformDeveloperPath,
  87.         this.sdkPath));
  88.   }
  89.  
  90.   /**
  91.    * Copy current immutable object by setting value for {@link AppleSdkPaths#platformDeveloperPath()}.
  92.    * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
  93.    * @param value value for platformDeveloperPath, non-null
  94.    * @return modified copy of the {@code this} object
  95.    */
  96.   public final ImmutableAppleSdkPaths withPlatformDeveloperPath(Path value) {
  97.     if (this.platformDeveloperPath == value) {
  98.       return this;
  99.     }
  100.     Path newValue = Preconditions.checkNotNull(value);
  101.     return checkPreconditions(new ImmutableAppleSdkPaths(
  102.         this,
  103.         this.toolchainPath,
  104.         newValue,
  105.         this.sdkPath));
  106.   }
  107.  
  108.   /**
  109.    * Copy current immutable object by setting value for {@link AppleSdkPaths#sdkPath()}.
  110.    * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
  111.    * @param value value for sdkPath, non-null
  112.    * @return modified copy of the {@code this} object
  113.    */
  114.   public final ImmutableAppleSdkPaths withSdkPath(Path value) {
  115.     if (this.sdkPath == value) {
  116.       return this;
  117.     }
  118.     Path newValue = Preconditions.checkNotNull(value);
  119.     return checkPreconditions(new ImmutableAppleSdkPaths(
  120.         this,
  121.         this.toolchainPath,
  122.         this.platformDeveloperPath,
  123.         newValue));
  124.   }
  125.  
  126.   @Override
  127.   public Path toolchainPath() {
  128.     return toolchainPath;
  129.   }
  130.  
  131.   @Override
  132.   public Path platformDeveloperPath() {
  133.     return platformDeveloperPath;
  134.   }
  135.  
  136.   @Override
  137.   public Path sdkPath() {
  138.     return sdkPath;
  139.   }
  140.  
  141.   @Override
  142.   public boolean equals(Object another) {
  143.     return this == another
  144.         || (another instanceof ImmutableAppleSdkPaths && equalTo((ImmutableAppleSdkPaths) another));
  145.   }
  146.  
  147.   private boolean equalTo(ImmutableAppleSdkPaths another) {
  148.     return toolchainPath.equals(another.toolchainPath)
  149.         && platformDeveloperPath.equals(another.platformDeveloperPath)
  150.         && sdkPath.equals(another.sdkPath);
  151.   }
  152.  
  153.   private int computeHashCode() {
  154.     int h = 31;
  155.     h = h * 17 + toolchainPath.hashCode();
  156.     h = h * 17 + platformDeveloperPath.hashCode();
  157.     h = h * 17 + sdkPath.hashCode();
  158.     return h;
  159.   }
  160.  
  161.   @Override
  162.   public int hashCode() {
  163.     return computeHashCode();
  164.   }
  165.  
  166.   @Override
  167.   public String toString() {
  168.     return MoreObjects.toStringHelper("AppleSdkPaths")
  169.         .add("toolchainPath", toolchainPath)
  170.         .add("platformDeveloperPath", platformDeveloperPath)
  171.         .add("sdkPath", sdkPath)
  172.         .toString();
  173.   }
  174.  
  175.   /**
  176.    * Creates builder for {@link AppleSdkPaths}.
  177.    * @return new AppleSdkPaths builder
  178.    */
  179.   public static Builder builder() {
  180.     return new Builder();
  181.   }
  182.  
  183.   /**
  184.    * Builds instances of {@link AppleSdkPaths}.
  185.    * Builder is not thread safe and generally should not be stored in fields and collections,
  186.    * but used immediately to create instances.
  187.    */
  188.   @NotThreadSafe
  189.   public static final class Builder {
  190.     private Builder() {
  191.     }
  192.  
  193.     private long initializedBitset0;
  194.     private static final long INITIALIZED_BITSET_ALL_0 = 0x7;
  195.     private static final long INITIALIZED_BIT_TOOLCHAIN_PATH = 0x1L;
  196.  
  197.     private boolean toolchainPathIsSet() {
  198.       return (initializedBitset0 & INITIALIZED_BIT_TOOLCHAIN_PATH) != 0;
  199.     }
  200.     private static final long INITIALIZED_BIT_PLATFORM_DEVELOPER_PATH = 0x2L;
  201.  
  202.     private boolean platformDeveloperPathIsSet() {
  203.       return (initializedBitset0 & INITIALIZED_BIT_PLATFORM_DEVELOPER_PATH) != 0;
  204.     }
  205.     private static final long INITIALIZED_BIT_SDK_PATH = 0x4L;
  206.  
  207.     private boolean sdkPathIsSet() {
  208.       return (initializedBitset0 & INITIALIZED_BIT_SDK_PATH) != 0;
  209.     }
  210.     @Nullable
  211.     private Path toolchainPath;
  212.     @Nullable
  213.     private Path platformDeveloperPath;
  214.     @Nullable
  215.     private Path sdkPath;
  216.  
  217.     @Override
  218.     public String toString() {
  219.       return MoreObjects.toStringHelper("AppleSdkPaths.Builder")
  220.           .omitNullValues()
  221.           .add("toolchainPath", toolchainPath)
  222.           .add("platformDeveloperPath", platformDeveloperPath)
  223.           .add("sdkPath", sdkPath)
  224.           .toString();
  225.     }
  226.  
  227.     /**
  228.      * Initializes value for {@link AppleSdkPaths#toolchainPath()}.
  229.      * @param toolchainPath value for toolchainPath, non-null
  230.      * @return {@code this} builder for chained invocation
  231.      */
  232.     public final Builder toolchainPath(Path toolchainPath) {
  233.       this.toolchainPath = Preconditions.checkNotNull(toolchainPath);
  234.       initializedBitset0 |= INITIALIZED_BIT_TOOLCHAIN_PATH;
  235.       return this;
  236.     }
  237.  
  238.     /**
  239.      * Initializes value for {@link AppleSdkPaths#platformDeveloperPath()}.
  240.      * @param platformDeveloperPath value for platformDeveloperPath, non-null
  241.      * @return {@code this} builder for chained invocation
  242.      */
  243.     public final Builder platformDeveloperPath(Path platformDeveloperPath) {
  244.       this.platformDeveloperPath = Preconditions.checkNotNull(platformDeveloperPath);
  245.       initializedBitset0 |= INITIALIZED_BIT_PLATFORM_DEVELOPER_PATH;
  246.       return this;
  247.     }
  248.  
  249.     /**
  250.      * Initializes value for {@link AppleSdkPaths#sdkPath()}.
  251.      * @param sdkPath value for sdkPath, non-null
  252.      * @return {@code this} builder for chained invocation
  253.      */
  254.     public final Builder sdkPath(Path sdkPath) {
  255.       this.sdkPath = Preconditions.checkNotNull(sdkPath);
  256.       initializedBitset0 |= INITIALIZED_BIT_SDK_PATH;
  257.       return this;
  258.     }
  259.  
  260.     private void checkRequiredAttributes() {
  261.       if (initializedBitset0 != INITIALIZED_BITSET_ALL_0) {
  262.         throw new IllegalStateException(
  263.             MoreObjects.toStringHelper("Cannot build AppleSdkPaths, some of required attributes are not set ")
  264.                 .omitNullValues()
  265.                 .addValue(!toolchainPathIsSet() ? "toolchainPath" : null)
  266.                 .addValue(!platformDeveloperPathIsSet() ? "platformDeveloperPath" : null)
  267.                 .addValue(!sdkPathIsSet() ? "sdkPath" : null)
  268.                 .toString());
  269.       }
  270.     }
  271.  
  272.     /**
  273.      * Builds new {@link AppleSdkPaths}.
  274.      * @return immutable instance of AppleSdkPaths
  275.      */
  276.     public ImmutableAppleSdkPaths build() {
  277.       checkRequiredAttributes();
  278.       return checkPreconditions(new ImmutableAppleSdkPaths(this));
  279.     }
  280.   }
  281. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement