diff options
Diffstat (limited to 'platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project')
2 files changed, 74 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); } } diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/IExternalSystemSourceType.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/IExternalSystemSourceType.java new file mode 100644 index 000000000000..2ad8821b06cd --- /dev/null +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/project/IExternalSystemSourceType.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.externalSystem.model.project; + +import java.io.Serializable; + +/** + * @author Vladislav.Soroka + * @since 7/17/2014 + */ +public interface IExternalSystemSourceType extends Serializable { + boolean isTest(); + + boolean isGenerated(); + + boolean isResource(); + + boolean isExcluded(); +} |