fixing serialization for android gradle model
authorDmitry Avdeev <dmitry.avdeev@jetbrains.com>
Thu, 14 Nov 2019 09:39:43 +0000 (12:39 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Thu, 14 Nov 2019 10:11:31 +0000 (10:11 +0000)
default constructors are required by new gradle model serialization engine

GitOrigin-RevId: 8e4257028de1aa5d76a306fb4f92bb75447d824d

49 files changed:
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeAaptOptions.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeAndroidArtifactImpl.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeAndroidArtifactOutput.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeAndroidBundle.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeAndroidLibrary.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeAndroidProjectImpl.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeApiVersion.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeBaseArtifactImpl.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeBaseConfig.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeBuildType.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeBuildTypeContainer.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeClassField.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeDependenciesImpl.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeDependencyGraphs.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeFilterData.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeGraphItem.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeInstantRun.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeJavaArtifact.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeJavaCompileOptions.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeJavaLibrary.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeLibrary.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeLintOptions.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeMavenCoordinates.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeModel.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeNativeAndroidProjectImpl.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeNativeArtifact.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeNativeFile.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeNativeLibrary.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeNativeSettings.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeNativeToolchain.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeNativeVariantAbi.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeOutputFile.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeProductFlavor.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeProductFlavorContainer.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeProjectIdentifierImpl.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeSigningConfig.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeSourceProvider.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeSourceProviderContainer.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeSyncIssue.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeTestOptions.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeTestedTargetVariant.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeVariantImpl.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeVariantOutput.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/IdeVectorDrawablesOptions.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/level2/IdeAndroidLibrary.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/level2/IdeDependenciesImpl.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/level2/IdeJavaLibrary.java
sdk-common/src/main/java/com/android/ide/common/gradle/model/level2/IdeModuleLibrary.java
sdk-common/src/main/java/com/android/ide/common/repository/GradleVersion.java

index ed3db2c71c5be337768a17725d336a6360e35824..d3cda24d92befe61a57ead68503fdc967c0811f9 100644 (file)
@@ -44,6 +44,16 @@ public class IdeAaptOptions extends IdeModel implements AaptOptions {
         failOnMissingConfigEntry = copyNewProperty(original::getFailOnMissingConfigEntry, false);
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeAaptOptions() {
+        this.ignoreAssets = null;
+        this.noCompress = null;
+        this.failOnMissingConfigEntry = false;
+        this.additionalParameters = null;
+        this.namespacing = null;
+    }
+
     @Override
     @Nullable
     public String getIgnoreAssets() {
index 572c6452ee4a0a1bd25934bfe12acaf2b28f5cbd..b1013c96f9e82d8bc21779bd7f2f0083829d4426 100644 (file)
@@ -47,7 +47,6 @@ public final class IdeAndroidArtifactImpl extends IdeBaseArtifactImpl
     @Nullable private final String myApkFromBundleTaskName;
 
     private final boolean mySigned;
-    private final int myHashCode;
 
     public IdeAndroidArtifactImpl(
             @NonNull AndroidArtifact artifact,
@@ -99,7 +98,28 @@ public final class IdeAndroidArtifactImpl extends IdeBaseArtifactImpl
         myApkFromBundleTaskName =
                 copyNewProperty(
                         modelCache, artifact::getApkFromBundleTaskName, taskName -> taskName, null);
-        myHashCode = calculateHashCode();
+    }
+
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeAndroidArtifactImpl() {
+        super();
+        myOutputs = null;
+        myApplicationId = null;
+        mySourceGenTaskName = null;
+        myGeneratedResourceFolders = null;
+        myAdditionalRuntimeApks = null;
+        myBuildConfigFields = null;
+        myResValues = null;
+        myInstantRun = null;
+        mySigningConfigName = null;
+        myAbiFilters = null;
+        myNativeLibraries = null;
+        myTestOptions = null;
+        myInstrumentedTestTaskName = null;
+        myBundleTaskName = null;
+        myApkFromBundleTaskName = null;
+        mySigned = false;
     }
 
     @NonNull
@@ -262,11 +282,6 @@ public final class IdeAndroidArtifactImpl extends IdeBaseArtifactImpl
     }
 
     @Override
-    public int hashCode() {
-        return myHashCode;
-    }
-
-    @Override
     protected int calculateHashCode() {
         return Objects.hash(
                 super.calculateHashCode(),
index 125fe2dfbf4b854d6fb9f6007ffe7e65ee5fb360..8bb97b3bc653ca0aa3d59dca4214efbdb70161d3 100644 (file)
@@ -29,7 +29,6 @@ public final class IdeAndroidArtifactOutput extends IdeVariantOutput
 
     @Nullable private final File myOutputFile;
     @Nullable private final String myAssembleTaskName;
-    private final int myHashCode;
 
     public IdeAndroidArtifactOutput(
             @NonNull AndroidArtifactOutput output, @NonNull ModelCache modelCache) {
@@ -48,8 +47,14 @@ public final class IdeAndroidArtifactOutput extends IdeVariantOutput
         // do.
         myOutputFile =
                 copyNewProperty(output::getOutputFile, output.getMainOutputFile().getOutputFile());
+    }
 
-        myHashCode = calculateHashCode();
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeAndroidArtifactOutput() {
+        super();
+        myOutputFile = null;
+        myAssembleTaskName = null;
     }
 
     @Override
@@ -99,11 +104,6 @@ public final class IdeAndroidArtifactOutput extends IdeVariantOutput
     }
 
     @Override
-    public int hashCode() {
-        return myHashCode;
-    }
-
-    @Override
     protected int calculateHashCode() {
         return Objects.hash(super.calculateHashCode(), myAssembleTaskName, myOutputFile);
     }
index 8157e6a69d6d32fd6dddfbc1645431c4022adce6..5caae69bdb595b39fc141601649bb660fac7036f 100644 (file)
@@ -71,6 +71,23 @@ public abstract class IdeAndroidBundle extends IdeLibrary implements AndroidBund
         myHashCode = calculateHashCode();
     }
 
+    @SuppressWarnings("ConstantConditions")
+    protected IdeAndroidBundle() {
+        super();
+        myBundle = null;
+        myFolder = null;
+        myLibraryDependencies = null;
+        myJavaDependencies = null;
+        myManifest = null;
+        myJarFile = null;
+        myCompileJarFile = null;
+        myResFolder = null;
+        myResStaticLibrary = null;
+        myAssetsFolder = null;
+        myProjectVariant = null;
+        myHashCode = 0;
+    }
+
     @NonNull
     private static Collection<? extends JavaLibrary> copyJavaDependencies(
             @NonNull AndroidBundle bundle, @NonNull ModelCache modelCache) {
index fcb2127bd8448e13417d6d30fe43c7f36ea1ac54..c544edf65075fd7309a850580a8ca4b78c96fad9 100644 (file)
@@ -43,6 +43,17 @@ public final class IdeAndroidLibrary extends IdeAndroidBundle implements Android
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeAndroidLibrary() {
+        super();
+        myLocalJars = null;
+        myProguardRules = null;
+        myLintJar = null;
+        myPublicResources = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public Collection<File> getLocalJars() {
index 64374d7a6c523bd834ee1e5d63e956d74d02a009..6085bf528f1a0d5c0a79bf41d17f861ccc2536b2 100644 (file)
@@ -186,6 +186,40 @@ public final class IdeAndroidProjectImpl extends IdeModel implements IdeAndroidP
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeAndroidProjectImpl() {
+        myModelVersion = null;
+        myName = null;
+        myDefaultConfig = null;
+        myBuildTypes = null;
+        myProductFlavors = null;
+        mySyncIssues = null;
+        myVariants = null;
+        myVariantNames = null;
+        myDefaultVariant = null;
+        myFlavorDimensions = null;
+        myCompileTarget = null;
+        myBootClassPath = null;
+        myNativeToolchains = null;
+        mySigningConfigs = null;
+        myLintOptions = null;
+        myUnresolvedDependencies = null;
+        myJavaCompileOptions = null;
+        myAaptOptions = null;
+        myBuildFolder = null;
+        myDynamicFeatures = null;
+        myParsedModelVersion = null;
+        myBuildToolsVersion = null;
+        myResourcePrefix = null;
+        mySupportsPluginGeneration = false;
+        myApiVersion = 0;
+        myLibrary = false;
+        myProjectType = 0;
+        myBaseSplit = false;
+        myHashCode = 0;
+    }
+
     @NonNull
     private static ImmutableList<String> computeVariantNames(Collection<Variant> variants) {
         return variants.stream().map(Variant::getName).collect(ImmutableList.toImmutableList());
index 7278e6897edeeb29d26e5d2dab6b96cc45fbffc7..ed5589e87ae6050aaf608be28b69d36ed0b8aae1 100644 (file)
@@ -39,6 +39,15 @@ public final class IdeApiVersion extends IdeModel implements ApiVersion {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeApiVersion() {
+        myApiString = null;
+        myCodename = null;
+        myApiLevel = 0;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getApiString() {
index 460cb283619225c1e77f9596bf71832115a4d8be..517ff03efe11e62808f96c3040af9132940d70ae 100644 (file)
@@ -99,6 +99,26 @@ public abstract class IdeBaseArtifactImpl extends IdeModel implements IdeBaseArt
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"ConstantConditions"})
+    protected IdeBaseArtifactImpl() {
+        myName = null;
+        myCompileTaskName = null;
+        myAssembleTaskName = null;
+        myClassesFolder = null;
+        myDependencies = null;
+        myIdeSetupTaskNames = null;
+        myGeneratedSourceFolders = null;
+        myAdditionalClassFolders = null;
+        myLevel2Dependencies = null;
+        myCompileDependencies = null;
+        myJavaResourcesFolder = null;
+        myDependencyGraphs = null;
+        myVariantSourceProvider = null;
+        myMultiFlavorSourceProvider = null;
+        myHashCode = 0;
+    }
+
     @NonNull
     private static IdeDependencies copy(
             @NonNull Dependencies original,
index e6905c0ca4f8cec6ffbaf0ad3cf54d40274f6a1c..a152c970b085dacbf3daf061df7bfc10dd98ecbc 100644 (file)
@@ -60,6 +60,20 @@ public abstract class IdeBaseConfig extends IdeModel implements BaseConfig {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"ConstantConditions"})
+    protected IdeBaseConfig() {
+        myName = null;
+        myResValues = null;
+        myProguardFiles = null;
+        myConsumerProguardFiles = null;
+        myManifestPlaceholders = null;
+        myApplicationIdSuffix = null;
+        myVersionNameSuffix = null;
+        myMultiDexEnabled = false;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getName() {
index d92756a4236a7b0ef3a7cb31a0db19db023215d0..82f27435066d166a9bd0ae620511b6ec55775acf 100644 (file)
@@ -47,6 +47,19 @@ public final class IdeBuildType extends IdeBaseConfig implements BuildType {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused"})
+    private IdeBuildType() {
+        super();
+        myDebuggable = false;
+        myJniDebuggable = false;
+        myRenderscriptDebuggable = false;
+        myRenderscriptOptimLevel = 0;
+        myMinifyEnabled = false;
+        myZipAlignEnabled = false;
+        myHashCode = 0;
+    }
+
     @Override
     @Nullable
     public SigningConfig getSigningConfig() {
index f3918fa86280f79c4aeb5093691e0ee1fe71fea9..67d5fb20e49a40f6c2c157905458288c812a161d 100644 (file)
@@ -53,6 +53,15 @@ public final class IdeBuildTypeContainer extends IdeModel implements BuildTypeCo
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeBuildTypeContainer() {
+        myBuildType = null;
+        mySourceProvider = null;
+        myExtraSourceProviders = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public IdeBuildType getBuildType() {
index dccd60e0984d5bafa1a184a7e2986acee8b6bd8a..4d3323671022d715fac182621320287692aea15f 100644 (file)
@@ -39,6 +39,15 @@ public final class IdeClassField extends IdeModel implements ClassField {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeClassField() {
+        myName = null;
+        myType = null;
+        myValue = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getType() {
index c37f5d2cc2be86386735c9d2ee986a153ab8b290..0c002d845d8a229bd34a56872cc901a0c8ba3167 100644 (file)
@@ -75,6 +75,17 @@ public final class IdeDependenciesImpl extends IdeModel implements IdeDependenci
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeDependenciesImpl() {
+        myLibraries = null;
+        myJavaLibraries = null;
+        myProjects = null;
+        myJavaModules = null;
+        myRuntimeOnlyClasses = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public Collection<AndroidLibrary> getLibraries() {
index 23c4d0045187d8eeeb06eea07df5e01e24279e6a..1e9159d32bd35f807416c54abca15cc5ae8bf18c 100644 (file)
@@ -51,6 +51,16 @@ public final class IdeDependencyGraphs extends IdeModel implements DependencyGra
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeDependencyGraphs() {
+        myCompileDependencies = null;
+        myPackageDependencies = null;
+        myProvidedLibraries = null;
+        mySkippedLibraries = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public List<GraphItem> getCompileDependencies() {
index 935c54912e3293ee381455131699e66a70ea5042..8a2161399774862d280bc85c7a2fe12eb0eaaf7a 100644 (file)
@@ -36,6 +36,14 @@ public final class IdeFilterData extends IdeModel implements FilterData {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeFilterData() {
+        myIdentifier = null;
+        myFilterType = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getIdentifier() {
index 933a762f553286686ebebb82f9918eca89401314..cb471222d819d642dcb9b94b32e9e30783f642f6 100644 (file)
@@ -44,6 +44,15 @@ public final class IdeGraphItem extends IdeModel implements GraphItem {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeGraphItem() {
+        myArtifactAddress = null;
+        myDependencies = null;
+        myRequestedCoordinates = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getArtifactAddress() {
index 3ecfa0494ef80fa01e72aed158c59664953a4ccb..3f668da17e7ea020aab048e59706c0efb69dafd1 100644 (file)
@@ -39,6 +39,15 @@ public final class IdeInstantRun extends IdeModel implements InstantRun {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeInstantRun() {
+        myInfoFile = null;
+        mySupportedByArtifact = false;
+        mySupportStatus = 0;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public File getInfoFile() {
index 58a114cd0c0e37bfcb32a65d0ef1311d32b62152..ecdc70a8c9f797761f05b726dcf0c5937d06b6c0 100644 (file)
@@ -42,6 +42,14 @@ public final class IdeJavaArtifact extends IdeBaseArtifactImpl implements JavaAr
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeJavaArtifact() {
+        super();
+        myMockablePlatformJar = null;
+        myHashCode = 0;
+    }
+
     @Override
     @Nullable
     public File getMockablePlatformJar() {
index f8522d66bd6f22077891036be895fb6ae6e04b15..5717631d45f7c83d83fb8dfd222326c180e99ffb 100644 (file)
@@ -39,6 +39,15 @@ public final class IdeJavaCompileOptions extends IdeModel implements JavaCompile
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeJavaCompileOptions() {
+        myEncoding = null;
+        mySourceCompatibility = null;
+        myTargetCompatibility = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getEncoding() {
index a8fc4f79de013443295882a375029c6663941b06..8ae2f8e4b9d2b305d44bf3c4a1b102e70c0448e0 100644 (file)
@@ -42,6 +42,15 @@ public final class IdeJavaLibrary extends IdeLibrary implements JavaLibrary {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeJavaLibrary() {
+        super();
+        myJarFile = null;
+        myDependencies = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public File getJarFile() {
index 2ba2994b4298dab2499c3061f3463a82a700bf52..3dfeec25123c1e4c7c8e1d56577c2811a39d5c1c 100644 (file)
@@ -45,6 +45,16 @@ public abstract class IdeLibrary extends IdeModel implements Library {
         myHashCode = calculateHashCode();
     }
 
+    @SuppressWarnings("ConstantConditions")
+    protected IdeLibrary() {
+        myResolvedCoordinates = null;
+        myBuildId = null;
+        myProject = null;
+        myName = null;
+        myProvided = null;
+        myHashCode = 0;
+    }
+
     @Override
     @Nullable
     public IdeMavenCoordinates getRequestedCoordinates() {
index f17d09b3f8da612b30f3fabdb2785f5c1626463a..50f83710aae61c88159e475b4f8b9ab8af088fc5 100644 (file)
@@ -53,6 +53,15 @@ public final class IdeLintOptions extends IdeModel implements LintOptions {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeLintOptions() {
+        myBaselineFile = null;
+        mySeverityOverrides = null;
+        myCheckTestSources = false;
+        myHashCode = 0;
+    }
+
     @Nullable
     private static Map<String, Integer> copy(@Nullable Map<String, Integer> original) {
         return original != null ? ImmutableMap.copyOf(original) : null;
index ff8b8718982f70a47e2336fd60834cd97db05855..b55316b62e76a43a72d3dc256fdaacec522b8dd6 100644 (file)
@@ -55,6 +55,17 @@ public final class IdeMavenCoordinates extends IdeModel implements MavenCoordina
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeMavenCoordinates() {
+        myGroupId = null;
+        myArtifactId = null;
+        myVersion = null;
+        myPacking = null;
+        myClassifier = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getGroupId() {
index 843155ce9076ce853ae7a5bb6abdb2a5a57da5ff..76a3b1131fe1e85782bd23b5811a03a9e851838f 100644 (file)
@@ -38,6 +38,9 @@ public abstract class IdeModel implements Serializable {
         }
     }
 
+    protected IdeModel() {
+    }
+
     @Nullable
     protected static <K, V> V copyNewProperty(
             @NonNull ModelCache modelCache,
@@ -73,24 +76,24 @@ public abstract class IdeModel implements Serializable {
     }
 
     @NonNull
-    protected static <K, V> List<K> copy(
+    protected static <K, V> List<V> copy(
             @NonNull Collection<K> original,
             @NonNull ModelCache modelCache,
             @NonNull Function<K, V> mapper) {
         if (original.isEmpty()) {
             return Collections.emptyList();
         }
-        ImmutableList.Builder<K> copies = ImmutableList.builder();
+        ImmutableList.Builder<V> copies = ImmutableList.builder();
         for (K item : original) {
             V copy = modelCache.computeIfAbsent(item, mapper);
             //noinspection unchecked
-            copies.add((K) copy);
+            copies.add(copy);
         }
         return copies.build();
     }
 
     @NonNull
-    protected static <K, V> List<K> copy(
+    protected static <K, V> List<V> copy(
             @NonNull Supplier<Collection<K>> propertyInvoker,
             @NonNull ModelCache modelCache,
             @NonNull Function<K, V> mapper) {
index 0ab2b8a81c7ad333d62f8fa14c18e8b325063a84..f86beebe9239bf141247aff03e29d4272007f8c4 100644 (file)
@@ -81,6 +81,22 @@ public final class IdeNativeAndroidProjectImpl extends IdeModel implements IdeNa
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeNativeAndroidProjectImpl() {
+        myModelVersion = null;
+        myName = null;
+        myBuildFiles = null;
+        myVariantInfos = null;
+        myArtifacts = null;
+        myToolChains = null;
+        mySettings = null;
+        myFileExtensions = null;
+        myBuildSystems = null;
+        myApiVersion = 0;
+        myHashCode = 0;
+    }
+
     @NonNull
     private static Map<String, NativeVariantInfo> copyVariantInfos(
             @NonNull NativeAndroidProject project, @NonNull ModelCache modelCache) {
index f27bfb42d56860d351019c3c963f35196afb5da2..ce978143acfb786d23ad1d9e208036667f2c03ba 100644 (file)
@@ -52,6 +52,20 @@ public final class IdeNativeArtifact extends IdeModel implements NativeArtifact
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeNativeArtifact() {
+        myName = null;
+        myToolChain = null;
+        myGroupName = null;
+        mySourceFiles = null;
+        myExportedHeaders = null;
+        myOutputFile = null;
+        myAbi = null;
+        myTargetName = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getName() {
index 6214ab74e9321eba9812cd2584e8609edfa51317..597d77cac386c88143cb47b0aef8dced7829cbfd 100644 (file)
@@ -34,6 +34,15 @@ public final class IdeNativeFile extends IdeModel implements NativeFile {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeNativeFile() {
+        myFilePath = null;
+        mySettingsName = null;
+        myWorkingDirectory = null;
+        myHashCode = 0;
+    }
+
     @NonNull
     @Override
     public File getFilePath() {
index 17c93c35d1b4f23b77cedd7761503fa77b4a1b19..9188a3716480860755eddebf633e697779ba2e99 100644 (file)
@@ -59,6 +59,24 @@ public final class IdeNativeLibrary extends IdeModel implements NativeLibrary {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeNativeLibrary() {
+        myName = null;
+        myAbi = null;
+        myToolchainName = null;
+        myCIncludeDirs = null;
+        myCppIncludeDirs = null;
+        myCSystemIncludeDirs = null;
+        myCppSystemIncludeDirs = null;
+        myCDefines = null;
+        myCppDefines = null;
+        myCCompilerFlags = null;
+        myCppCompilerFlags = null;
+        myDebuggableLibraryFolders = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getName() {
index d0d2552d46311462ab0c0cb962aa95781dd5b316..9d98e9f83f5aaeb56e5a213fb333740970885e9a 100644 (file)
@@ -40,6 +40,14 @@ public final class IdeNativeSettings extends IdeModel implements NativeSettings
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeNativeSettings() {
+        myName = null;
+        myCompilerFlags = null;
+        myHashCode = 0;
+    }
+
     @NonNull
     @Override
     public String getName() {
index 2541da491906a70217c0981569eeb5977c566680..23b06f5cbe5979226662b374c7b203d25314bd53 100644 (file)
@@ -40,6 +40,15 @@ public final class IdeNativeToolchain extends IdeModel implements NativeToolchai
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeNativeToolchain() {
+        myName = null;
+        myCCompilerExecutable = null;
+        myCppCompilerExecutable = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getName() {
index 3294f0c034f9b7321a78ee86909ebe9e84beacd4..0f03fd3b82f7fea091763a621d34020b7c96f538 100644 (file)
@@ -71,6 +71,19 @@ public final class IdeNativeVariantAbi extends IdeModel implements NativeVariant
 
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeNativeVariantAbi() {
+        myBuildFiles = null;
+        myArtifacts = null;
+        myToolChains = null;
+        mySettings = null;
+        myFileExtensions = null;
+        myVariantName = null;
+        myAbi = null;
+        myHashCode = 0;
+    }
+
     @NonNull
     @Override
     public Collection<File> getBuildFiles() {
index 2b212eef228e02f15b1115e5ab6157d7b8dd0dbe..c5a2ce45d8e6019f20da3e38dea7ad8f97b65a19 100644 (file)
@@ -35,7 +35,7 @@ public final class IdeOutputFile extends IdeModel implements OutputFile {
     @NonNull private final Collection<String> myFilterTypes;
     @NonNull private final Collection<FilterData> myFilters;
     @NonNull private final File myOutputFile;
-    @NonNull private final Collection<? extends OutputFile> myOutputs;
+    @NonNull private final Collection<IdeOutputFile> myOutputs;
     @Nullable private final OutputFile myMainOutputFile;
     @Nullable private final Integer myVersionCode;
     private final int myHashCode;
@@ -60,8 +60,21 @@ public final class IdeOutputFile extends IdeModel implements OutputFile {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeOutputFile() {
+        myOutputType = null;
+        myFilterTypes = null;
+        myFilters = null;
+        myOutputFile = null;
+        myOutputs = null;
+        myMainOutputFile = null;
+        myVersionCode = null;
+        myHashCode = 0;
+    }
+
     @NonNull
-    private static Collection<? extends OutputFile> copyOutputs(
+    private static Collection<IdeOutputFile> copyOutputs(
             @NonNull OutputFile file, @NonNull ModelCache modelCache) {
         try {
             //noinspection deprecation
index 44135777b1b9d39c115760c43c9a1aae63ffb723..4c1bc2625696efc17bf31abdf58194aca25f045b 100644 (file)
@@ -68,6 +68,26 @@ public final class IdeProductFlavor extends IdeBaseConfig implements ProductFlav
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeProductFlavor() {
+        super();
+        myTestInstrumentationRunnerArguments = null;
+        myResourceConfigurations = null;
+        myVectorDrawables = null;
+        myDimension = null;
+        myApplicationId = null;
+        myVersionCode = null;
+        myVersionName = null;
+        myMinSdkVersion = null;
+        myTargetSdkVersion = null;
+        myMaxSdkVersion = null;
+        myTestApplicationId = null;
+        myTestInstrumentationRunner = null;
+        mySigningConfig = null;
+        myHashCode = 0;
+    }
+
     @Nullable
     private static VectorDrawablesOptions copyVectorDrawables(
             @NonNull ProductFlavor flavor, @NonNull ModelCache modelCache) {
index d106d0b89bf13fbe524d8615b8b58237faa1e6e2..ef0b6690ab9583720015df674ef64f7d8a175207 100644 (file)
@@ -55,6 +55,15 @@ public final class IdeProductFlavorContainer extends IdeModel implements Product
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeProductFlavorContainer() {
+        myProductFlavor = null;
+        mySourceProvider = null;
+        myExtraSourceProviders = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public ProductFlavor getProductFlavor() {
index beacf191fa8e3b3951925ba7c153e2f5358d7327..863a0f03da05e87161cc0ca8b627009bc0980e06 100644 (file)
@@ -33,6 +33,13 @@ public class IdeProjectIdentifierImpl extends IdeModel implements IdeProjectIden
         this.projectPath = projectIdentifier.getProjectPath();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeProjectIdentifierImpl() {
+        this.buildId = null;
+        this.projectPath = null;
+    }
+
     @NonNull
     @Override
     public String getBuildId() {
index 3a3e9a34b166eb4033927b023d2b9077e40f5920..96a06bc9f64b941958f10500b11085748a6f31f3 100644 (file)
@@ -44,6 +44,17 @@ public final class IdeSigningConfig extends IdeModel implements SigningConfig {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeSigningConfig() {
+        myName = null;
+        myStoreFile = null;
+        myStorePassword = null;
+        myKeyAlias = null;
+        myV1SigningEnabled = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getName() {
index b8fbebab65934ab63b612a1167c987ec48184ffe..400857a7b23ebca5ad033894f7d87717fef6c5ea 100644 (file)
@@ -62,6 +62,24 @@ public final class IdeSourceProvider extends IdeModel implements SourceProvider
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    public IdeSourceProvider() {
+        myName = null;
+        myManifestFile = null;
+        myJavaDirectories = null;
+        myResourcesDirectories = null;
+        myAidlDirectories = null;
+        myRenderscriptDirectories = null;
+        myCDirectories = null;
+        myCppDirectories = null;
+        myResDirectories = null;
+        myAssetsDirectories = null;
+        myJniLibsDirectories = null;
+        myShadersDirectories = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getName() {
index db83448e1bef39b69826f3170b194cd023a08529..4837913bc8a01a5d915ea7e31b39e12d0159ce5c 100644 (file)
@@ -40,6 +40,14 @@ public final class IdeSourceProviderContainer extends IdeModel implements Source
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeSourceProviderContainer() {
+        myArtifactName = null;
+        mySourceProvider = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getArtifactName() {
index f46e0785bee391ef77b8c86e9ae2c882a8858747..9453e0a4f44ad9a24d2b31ee109a3bd37cd6485f 100644 (file)
@@ -44,6 +44,17 @@ public final class IdeSyncIssue extends IdeModel implements SyncIssue {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeSyncIssue() {
+        myMessage = null;
+        myData = null;
+        myMultiLineMessage = null;
+        mySeverity = 0;
+        myType = 0;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getMessage() {
index 6c5d20cf5ac1ae5532be40d490669d512521f3cc..d6cf1175c030ceeb51510649feff3caf567a8c7f 100644 (file)
@@ -35,6 +35,14 @@ public class IdeTestOptions extends IdeModel implements TestOptions {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeTestOptions() {
+        myAnimationsDisabled = false;
+        myExecutionEnum = null;
+        myHashCode = 0;
+    }
+
     @Override
     public boolean getAnimationsDisabled() {
         return myAnimationsDisabled;
index 9a397afff3e0ac20afec9e8eaddf4fdf3d5b25b5..1c82e09eac2b8da37f36f3d906e0f3d7a2be740f 100644 (file)
@@ -37,6 +37,14 @@ public final class IdeTestedTargetVariant extends IdeModel implements TestedTarg
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeTestedTargetVariant() {
+        myTargetProjectPath = null;
+        myTargetVariant = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public String getTargetProjectPath() {
index 00963e8fada7db6e4448a27e9648ebca4555aa68..ff2495035220b4a02e86085a7e52b601b26a2c8d 100644 (file)
@@ -93,6 +93,22 @@ public final class IdeVariantImpl extends IdeModel implements IdeVariant {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeVariantImpl() {
+        myName = null;
+        myDisplayName = null;
+        myMainArtifact = null;
+        myExtraAndroidArtifacts = null;
+        myExtraJavaArtifacts = null;
+        myBuildType = null;
+        myProductFlavors = null;
+        myMergedFlavor = null;
+        myTestedTargetVariants = null;
+        myHashCode = 0;
+        myInstantAppCompatible = false;
+    }
+
     @NonNull
     private static Collection<TestedTargetVariant> getTestedTargetVariants(
             @NonNull Variant variant, @NonNull ModelCache modelCache) {
index e2f7f2768c8c7d596c0b81507214263192163d90..f58d9d36f36217cf5b78b986cd51331c3ea45aad 100644 (file)
@@ -30,7 +30,7 @@ public abstract class IdeVariantOutput extends IdeModel implements VariantOutput
     // Increase the value when adding/removing fields or when changing the serialization/deserialization mechanism.
     private static final long serialVersionUID = 1L;
 
-    @NonNull private final Collection<? extends OutputFile> myOutputs;
+    @NonNull private final Collection<IdeOutputFile> myOutputs;
     @NonNull private final Collection<String> myFilterTypes;
     @Nullable private final Collection<FilterData> myFilters;
     @Nullable private final OutputFile myMainOutputFile;
@@ -63,6 +63,16 @@ public abstract class IdeVariantOutput extends IdeModel implements VariantOutput
         myHashCode = calculateHashCode();
     }
 
+    protected IdeVariantOutput() {
+        myOutputs = null;
+        myFilterTypes = null;
+        myFilters = null;
+        myMainOutputFile = null;
+        myOutputType = null;
+        myVersionCode = 0;
+        myHashCode = 0;
+    }
+
     @Nullable
     private static Collection<FilterData> copyFilters(
             @NonNull VariantOutput output, @NonNull ModelCache modelCache) {
index 1a95c0fd97f7d230c98449e57662a047ab447818..96384bc484d0ced1831d54cd0020ac1008306852 100644 (file)
@@ -39,6 +39,14 @@ public final class IdeVectorDrawablesOptions extends IdeModel implements VectorD
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeVectorDrawablesOptions() {
+        myGeneratedDensities = null;
+        myUseSupportLibrary = null;
+        myHashCode = 0;
+    }
+
     @Override
     @Nullable
     public Set<String> getGeneratedDensities() {
index af8279b2d2de8197f8580b67fb63220430b5f10b..9c0a96ae976108cde8305ded6c26bd42e5745caf 100644 (file)
@@ -94,6 +94,31 @@ public final class IdeAndroidLibrary extends IdeModel implements Library {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeAndroidLibrary() {
+        myArtifactAddress = null;
+        myFolder = null;
+        myManifest = null;
+        myJarFile = null;
+        myCompileJarFile = null;
+        myResFolder = null;
+        resStaticLibrary = null;
+        myAssetsFolder = null;
+        myLocalJars = null;
+        myJniFolder = null;
+        myAidlFolder = null;
+        myRenderscriptFolder = null;
+        myProguardRules = null;
+        myLintJar = null;
+        myExternalAnnotations = null;
+        myPublicResources = null;
+        myArtifactFile = null;
+        mySymbolFile = null;
+        myType = 0;
+        myHashCode = 0;
+    }
+
     @Override
     public int getType() {
         return myType;
index 4977f4073231c393ce6aa7e33d4116d84e00095b..88e1f8c3a3892e0e6ca8bfc49e84b600e144c28e 100644 (file)
@@ -45,6 +45,16 @@ public class IdeDependenciesImpl implements IdeDependencies, Serializable {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeDependenciesImpl() {
+        myAndroidLibraries = null;
+        myJavaLibraries = null;
+        myModuleDependencies = null;
+        myRuntimeOnlyClasses = null;
+        myHashCode = 0;
+    }
+
     @Override
     @NonNull
     public Collection<Library> getAndroidLibraries() {
index 29034c85cc16bbde8e3a0291f6f68fb05c4e2af8..d72375ffde9306cd03dca3200b3e5f7967e073bb 100644 (file)
@@ -46,6 +46,15 @@ public final class IdeJavaLibrary extends IdeModel implements Library {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeJavaLibrary() {
+        myArtifactAddress = null;
+        myArtifactFile = null;
+        myType = 0;
+        myHashCode = 0;
+    }
+
     @Override
     public int getType() {
         return myType;
index b87109f7c97f091633b68ed086c2cad68faee402..6b75a26e9a190d8cb4e4dd76b0b3a6937db08cfc 100644 (file)
@@ -89,6 +89,17 @@ public final class IdeModuleLibrary extends IdeModel implements Library {
         myHashCode = calculateHashCode();
     }
 
+    // for serialization
+    @SuppressWarnings({"unused", "ConstantConditions"})
+    private IdeModuleLibrary() {
+        myArtifactAddress = null;
+        myBuildId = null;
+        myProjectPath = null;
+        myVariant = null;
+        myType = 0;
+        myHashCode = 0;
+    }
+
     @Override
     public int getType() {
         return myType;
index 38917327931ddf22ff52c37c6a88ffadc70ddd1d..1c97cb95bf6cada38240736a69fc66879582c343 100644 (file)
@@ -241,6 +241,18 @@ public class GradleVersion implements Comparable<GradleVersion>, Serializable {
         mQualifiers = qualifiers;
     }
 
+    private GradleVersion() {
+        this.mRawValue = null;
+        this.mMajorSegment = null;
+        this.mMinorSegment = null;
+        this.mMicroSegment = null;
+        this.mPreview = 0;
+        this.mPreviewType = null;
+        this.mSnapshot = false;
+        this.mAdditionalSegments = null;
+        this.mQualifiers = null;
+    }
+
     public int getMajor() {
         return valueOf(mMajorSegment);
     }
@@ -469,6 +481,13 @@ public class GradleVersion implements Comparable<GradleVersion>, Serializable {
             }
         }
 
+        // for serialization
+        @SuppressWarnings({"unused", "ConstantConditions"})
+        private VersionSegment() {
+            this.mText = null;
+            this.mValue = 0;
+        }
+
         @NonNull
         public String getText() {
             return mText;