All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.flexmojos.oss.matcher.artifact.DependencyMatcher Maven / Gradle / Ivy

There is a newer version: 7.1.1
Show newest version
/**
 * Flexmojos is a set of maven goals to allow maven users to compile, optimize and test Flex SWF, Flex SWC, Air SWF and Air SWC.
 * Copyright (C) 2008-2012  Marvin Froeder 
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */
package net.flexmojos.oss.matcher.artifact;

import static org.hamcrest.Matchers.equalTo;

import org.apache.maven.model.Dependency;
import org.hamcrest.Matcher;

public class DependencyMatcher
{
    private static class ArtifactIdMatcher
        extends AbstractArtifactMatcher
    {
        ArtifactIdMatcher( Matcher elementMatcher )
        {
            super( elementMatcher, "artifactId" );
        }

        @Override
        protected String getValue( Dependency item )
        {
            return item.getArtifactId();
        }
    }

    private static class ClassifierMatcher
        extends AbstractArtifactMatcher
    {
        public ClassifierMatcher( Matcher elementMatcher )
        {
            super( elementMatcher, "classifier" );
        }

        @Override
        protected String getValue( Dependency item )
        {
            return item.getClassifier();
        }
    }

    private static class GroupIdMatcher
        extends AbstractArtifactMatcher
    {
        public GroupIdMatcher( Matcher elementMatcher )
        {
            super( elementMatcher, "groupId" );
        }

        @Override
        protected String getValue( Dependency item )
        {
            return item.getGroupId();
        }
    }

    private static class ScopeMatcher
        extends AbstractArtifactMatcher
    {
        public ScopeMatcher( Matcher elementMatcher )
        {
            super( elementMatcher, "scope" );
        }

        @Override
        protected String getValue( Dependency item )
        {
            return item.getScope();
        }
    }

    private static class TypeMatcher
        extends AbstractArtifactMatcher
    {
        public TypeMatcher( Matcher elementMatcher )
        {
            super( elementMatcher, "type" );
        }

        @Override
        protected String getValue( Dependency item )
        {
            return item.getType();
        }
    }

    private static class VersionMatcher
        extends AbstractArtifactMatcher
    {
        public VersionMatcher( Matcher elementMatcher )
        {
            super( elementMatcher, "version" );
        }

        @Override
        protected String getValue( Dependency item )
        {
            return item.getVersion();
        }
    }

    static
    {
        new DependencyMatcher();
    }

    public static ArtifactIdMatcher artifactId( Matcher artifactId )
    {
        return new ArtifactIdMatcher( artifactId );
    }

    public static ArtifactIdMatcher artifactId( String artifactId )
    {
        return artifactId( equalTo( artifactId ) );
    }

    public static ClassifierMatcher classifier( Matcher classifier )
    {
        return new ClassifierMatcher( classifier );
    }

    public static ClassifierMatcher classifier( String classifier )
    {
        return classifier( equalTo( classifier ) );
    }

    public static GroupIdMatcher groupId( Matcher groupId )
    {
        return new GroupIdMatcher( groupId );
    }

    public static GroupIdMatcher groupId( String groupId )
    {
        return groupId( equalTo( groupId ) );
    }

    public static ScopeMatcher scope( Matcher scope )
    {
        return new ScopeMatcher( scope );
    }

    public static ScopeMatcher scope( String scope )
    {
        return scope( equalTo( scope ) );
    }

    public static TypeMatcher type( Matcher type )
    {
        return new TypeMatcher( type );
    }

    public static TypeMatcher type( String type )
    {
        return type( equalTo( type ) );
    }

    public static VersionMatcher version( Matcher versionMatcher )
    {
        return new VersionMatcher( versionMatcher );
    }

    public static VersionMatcher version( String version )
    {
        return version( equalTo( version ) );
    }

    private DependencyMatcher()
    {
        super();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy