<commit_before>/**
 *  Copyright 2005-2015 Red Hat, Inc.
 *
 *  Red Hat licenses this file to you 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 io.fabric8.forge.addon.utils;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import org.jboss.forge.addon.dependencies.Dependency;
import org.jboss.forge.addon.projects.Project;
import org.jboss.forge.addon.projects.facets.DependencyFacet;

public class CamelProjectHelper {

    public static Dependency findCamelCoreDependency(Project project) {
        return findCamelArtifactDependency(project, "camel-core");
    }

    public static boolean hasFunktionDependency(Project project) {
        return hasDependency(project, "io.fabric8.funktion", "funktion-runtime");
    }

    public static Dependency findCamelSpringDependency(Project project) {
        return findCamelArtifactDependency(project, "camel-spring");
    }

    public static Dependency findCamelSpringBootDependency(Project project) {
        return findCamelArtifactDependency(project, "camel-spring-boot");
    }

    public static Dependency findCamelCDIDependency(Project project) {
        return findCamelArtifactDependency(project, "camel-cdi");
    }

    public static Dependency findCamelBlueprintDependency(Project project) {
        return findCamelArtifactDependency(project, "camel-blueprint");
    }

    public static Dependency findCamelArtifactDependency(Project project, String artifactId) {
        List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
        for (Dependency d : dependencies) {
            if ("org.apache.camel".equals(d.getCoordinate().getGroupId()) && artifactId.equals(d.getCoordinate().getArtifactId())) {
                return d;
            }
        }
        return null;
    }

    public static Set<Dependency> findCamelArtifacts(Project project) {
        Set<Dependency> answer = new LinkedHashSet<Dependency>();

        List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
        for (Dependency d : dependencies) {
            if ("org.apache.camel".equals(d.getCoordinate().getGroupId())) {
                answer.add(d);
            }
        }
        return answer;
    }

    public static boolean hasDependency(Project project, String groupId) {
        return hasDependency(project, groupId, null, null);
    }

    public static boolean hasDependency(Project project, String groupId, String artifactId) {
        return hasDependency(project, groupId, artifactId, null);
    }

    public static boolean hasDependency(Project project, String groupId, String artifactId, String version) {
        List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
        for (Dependency d : dependencies) {
            boolean match = d.getCoordinate().getGroupId().equals(groupId);
            if (match && artifactId != null) {
                match = d.getCoordinate().getArtifactId().equals(artifactId);
            }
            if (match && version != null) {
                match = d.getCoordinate().getVersion().equals(version);
            }
            if (match) {
                return match;
            }
        }
        return false;
    }
<commit_msg>Fixes issue#532 wildfly-swarm support when doing fabric8-setup<commit_after>/**
 *  Copyright 2005-2015 Red Hat, Inc.
 *
 *  Red Hat licenses this file to you 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 io.fabric8.forge.addon.utils;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import org.jboss.forge.addon.dependencies.Dependency;
import org.jboss.forge.addon.projects.Project;
import org.jboss.forge.addon.projects.facets.DependencyFacet;

public class CamelProjectHelper {

    public static Dependency findCamelCoreDependency(Project project) {
        return findCamelArtifactDependency(project, "camel-core");
    }

    public static boolean hasFunktionDependency(Project project) {
        return hasDependency(project, "io.fabric8.funktion", "funktion-runtime");
    }

    public static Dependency findCamelSpringDependency(Project project) {
        return findCamelArtifactDependency(project, "camel-spring");
    }

    public static Dependency findCamelSpringBootDependency(Project project) {
        return findCamelArtifactDependency(project, "camel-spring-boot");
    }

    public static Dependency findCamelCDIDependency(Project project) {
        return findCamelArtifactDependency(project, "camel-cdi");
    }

    public static Dependency findCamelBlueprintDependency(Project project) {
        return findCamelArtifactDependency(project, "camel-blueprint");
    }

    public static Dependency findCamelArtifactDependency(Project project, String artifactId) {
        List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
        for (Dependency d : dependencies) {
            if ("org.apache.camel".equals(d.getCoordinate().getGroupId()) && artifactId.equals(d.getCoordinate().getArtifactId())) {
                return d;
            }
        }
        return null;
    }

    public static Set<Dependency> findCamelArtifacts(Project project) {
        Set<Dependency> answer = new LinkedHashSet<Dependency>();

        List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
        for (Dependency d : dependencies) {
            if ("org.apache.camel".equals(d.getCoordinate().getGroupId())) {
                answer.add(d);
            }
        }
        return answer;
    }

    public static boolean hasDependency(Project project, String groupId) {
        return hasDependency(project, groupId, null, null) ||
                hasManagedDependency(project, groupId, null, null);
    }

    public static boolean hasDependency(Project project, String groupId, String artifactId) {
        return hasDependency(project, groupId, artifactId, null) ||
                hasManagedDependency(project, groupId, artifactId, null);
    }

    public static boolean hasDependency(Project project, String groupId, String artifactId, String version) {
        List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
        for (Dependency d : dependencies) {
            boolean match = d.getCoordinate().getGroupId().equals(groupId);
            if (match && artifactId != null) {
                match = d.getCoordinate().getArtifactId().equals(artifactId);
            }
            if (match && version != null) {
                match = d.getCoordinate().getVersion().equals(version);
            }
            if (match) {
                return match;
            }
        }
        return false;
    }

    public static boolean hasManagedDependency(Project project, String groupId, String artifactId, String version) {
        List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getManagedDependencies();
        for (Dependency d : dependencies) {
            boolean match = d.getCoordinate().getGroupId().equals(groupId);
            if (match && artifactId != null) {
                match = d.getCoordinate().getArtifactId().equals(artifactId);
            }
            if (match && version != null) {
                match = d.getCoordinate().getVersion().equals(version);
            }
            if (match) {
                return match;
            }
        }
        return false;
    }

{'fraction_non_alphanumeric': 0.09464348231999066, 'fraction_numerical': 0.003734391410899755, 'mean_word_length': 2.993476234855545, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7153670', 'n_tokens_mistral': 2299, 'n_tokens_neox': 2183, 'n_words': 579}