update copyright
[fedora-idea.git] / java / idea-ui / src / com / intellij / facet / impl / autodetecting / DisabledAutodetectionInfo.java
blobd672e1e2a7c1405d5bdbc28163c1acc151d054df
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.intellij.facet.impl.autodetecting;
19 import com.intellij.util.xmlb.annotations.AbstractCollection;
20 import com.intellij.util.xmlb.annotations.Tag;
21 import org.jetbrains.annotations.NotNull;
22 import org.jetbrains.annotations.Nullable;
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.Iterator;
28 /**
29 * @author nik
31 public class DisabledAutodetectionInfo {
32 private List<DisabledAutodetectionByTypeElement> myElements = new ArrayList<DisabledAutodetectionByTypeElement>();
34 @Tag("autodetection-disabled")
35 @AbstractCollection(surroundWithTag = false)
36 public List<DisabledAutodetectionByTypeElement> getElements() {
37 return myElements;
40 public void setElements(final List<DisabledAutodetectionByTypeElement> elements) {
41 myElements = elements;
44 public boolean isDisabled(final @NotNull String facetType, final @NotNull String moduleName, String url) {
45 DisabledAutodetectionByTypeElement element = findElement(facetType);
46 return element != null && element.isDisabled(moduleName, url);
49 public void replaceElement(@NotNull String facetTypeId, @Nullable DisabledAutodetectionByTypeElement element) {
50 Iterator<DisabledAutodetectionByTypeElement> iterator = myElements.iterator();
51 while (iterator.hasNext()) {
52 DisabledAutodetectionByTypeElement typeElement = iterator.next();
53 if (typeElement.getFacetTypeId().equals(facetTypeId)) {
54 iterator.remove();
55 break;
58 if (element != null) {
59 myElements.add(element);
63 @Nullable
64 public DisabledAutodetectionByTypeElement findElement(@NotNull String facetTypeId) {
65 for (DisabledAutodetectionByTypeElement element : myElements) {
66 if (facetTypeId.equals(element.getFacetTypeId())) {
67 return element;
70 return null;
73 public void addDisabled(final @NotNull String facetTypeId) {
74 DisabledAutodetectionByTypeElement element = findElement(facetTypeId);
75 if (element != null) {
76 element.disableInProject();
78 else {
79 myElements.add(new DisabledAutodetectionByTypeElement(facetTypeId));
83 public void addDisabled(final @NotNull String facetTypeId, final @NotNull String moduleName) {
84 DisabledAutodetectionByTypeElement element = findElement(facetTypeId);
85 if (element != null) {
86 element.addDisabled(moduleName);
88 else {
89 myElements.add(new DisabledAutodetectionByTypeElement(facetTypeId, moduleName));
93 public void addDisabled(final @NotNull String facetTypeId, final @NotNull String moduleName, String url, final boolean recursively) {
94 DisabledAutodetectionByTypeElement element = findElement(facetTypeId);
95 if (element != null) {
96 element.addDisabled(moduleName, url, recursively);
98 else {
99 myElements.add(new DisabledAutodetectionByTypeElement(facetTypeId, moduleName, url, recursively));
103 public void addDisabled(final @NotNull String facetTypeId, final @NotNull String moduleName, final @NotNull String... urls) {
104 for (String url : urls) {
105 addDisabled(facetTypeId, moduleName, url, false);