summaryrefslogtreecommitdiff
path: root/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java')
-rw-r--r--platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java74
1 files changed, 42 insertions, 32 deletions
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java
index ffe8a52d4a06..0e112b1c2b14 100644
--- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java
+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/ExternalSystemSourceType.java
@@ -1,52 +1,62 @@
package com.intellij.openapi.externalSystem.model.project;
-import org.jetbrains.annotations.NotNull;
-
-import java.io.Serializable;
-
/**
* Enumerates module source types.
*
* @author Denis Zhdanov
* @since 8/10/11 5:21 PM
*/
-public class ExternalSystemSourceType implements Serializable {
-
- @NotNull public static final ExternalSystemSourceType SOURCE = new ExternalSystemSourceType("SOURCE");
- @NotNull public static final ExternalSystemSourceType TEST = new ExternalSystemSourceType("TEST");
- @NotNull public static final ExternalSystemSourceType EXCLUDED = new ExternalSystemSourceType("EXCLUDED");
- @NotNull public static final ExternalSystemSourceType SOURCE_GENERATED = new ExternalSystemSourceType("SOURCE_GENERATED");
- @NotNull public static final ExternalSystemSourceType TEST_GENERATED = new ExternalSystemSourceType("TEST_GENERATED");
- @NotNull public static final ExternalSystemSourceType RESOURCE = new ExternalSystemSourceType("RESOURCE");
- @NotNull public static final ExternalSystemSourceType TEST_RESOURCE = new ExternalSystemSourceType("TEST_RESOURCE");
-
- private static final long serialVersionUID = 1L;
-
- @NotNull private final String myId;
-
- public ExternalSystemSourceType(@NotNull String id) {
- myId = id;
+public enum ExternalSystemSourceType implements IExternalSystemSourceType {
+
+ SOURCE(false, false, false, false),
+ TEST(true, false, false, false),
+ EXCLUDED(false, false, false, true),
+ SOURCE_GENERATED(true, true, false, false),
+ TEST_GENERATED(true, true, false, false),
+ RESOURCE(false, false, true, false),
+ TEST_RESOURCE(true, false, true, false);
+
+ private final boolean isTest;
+ private final boolean isGenerated;
+ private final boolean isResource;
+ private final boolean isExcluded;
+
+ ExternalSystemSourceType(boolean test, boolean generated, boolean resource, boolean excluded) {
+ isTest = test;
+ isGenerated = generated;
+ isResource = resource;
+ isExcluded = excluded;
}
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- ExternalSystemSourceType type = (ExternalSystemSourceType)o;
-
- if (!myId.equals(type.myId)) return false;
+ public boolean isTest() {
+ return isTest;
+ }
- return true;
+ @Override
+ public boolean isGenerated() {
+ return isGenerated;
}
@Override
- public int hashCode() {
- return myId.hashCode();
+ public boolean isResource() {
+ return isResource;
}
@Override
- public String toString() {
- return myId;
+ public boolean isExcluded() {
+ return isExcluded;
+ }
+
+ public static ExternalSystemSourceType from(IExternalSystemSourceType sourceType) {
+ for (ExternalSystemSourceType systemSourceType : ExternalSystemSourceType.values()) {
+ if (systemSourceType.isGenerated == sourceType.isGenerated() &&
+ systemSourceType.isResource == sourceType.isResource() &&
+ systemSourceType.isTest == sourceType.isTest() &&
+ systemSourceType.isExcluded == sourceType.isExcluded()) {
+ return systemSourceType;
+ }
+ }
+ throw new IllegalArgumentException("Invalid source type: " + sourceType);
}
}