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

com.marvelution.testing.maven.stubs.artifact.ArtifactStub Maven / Gradle / Ivy

/*
 * Licensed to Marvelution under one or more contributor license 
 * agreements.  See the NOTICE file distributed with this work 
 * for additional information regarding copyright ownership.
 * Marvelution 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 com.marvelution.testing.maven.stubs.artifact;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;

/**
 * Artifact Stub
 * 
 * @author Mark Rekveld
 */
public class ArtifactStub extends org.apache.maven.plugin.testing.stubs.ArtifactStub implements Artifact {

	/**
	 * The {@link ArtifactHandler}
	 */
	private ArtifactHandler handler;

	/**
	 * The classifier of the artifact
	 */
	private String classifier;

	/**
	 * The type of the Artifact
	 */
	private String type = "jar";

	/**
	 * Optional flag
	 */
	private boolean optional;

	/**
	 * Default Constructor
	 */
	public ArtifactStub() {
	}

	/**
	 * Constructor
	 * 
	 * @param groupId the groupId of the Artifact
	 * @param artifactId the artifactId of the Artifact
	 * @param version the version of the Artifact
	 */
	public ArtifactStub(String groupId, String artifactId, String version) {
		setGroupId(groupId);
		setArtifactId(artifactId);
		setVersion(version);
	}

	/**
	 * Constructor
	 * 
	 * @param groupId the groupId of the Artifact
	 * @param artifactId the artifactId of the Artifact
	 * @param version the version of the Artifact
	 * @param type the type of the Artifact
	 */
	public ArtifactStub(String groupId, String artifactId, String version, String type) {
		setGroupId(groupId);
		setArtifactId(artifactId);
		setVersion(version);
		setType(type);
	}

	/**
	 * {@inheritDoc}
	 */
	public ArtifactHandler getArtifactHandler() {
		if (handler == null) {
			handler = new DefaultArtifactHandler(getType());
		}
		return handler;
	}

	/**
	 * {@inheritDoc}
	 */
	public void setArtifactHandler(ArtifactHandler artifactHandler) {
		handler = artifactHandler;
	}

	/**
	 * Gets the classifier of the {@link Artifact}
	 * 
	 * @return the classifier
	 */
	public String getClassifier() {
		return classifier;
	}

	/**
	 * Sets the classifier of the {@link Artifact}
	 * 
	 * @param classifier the classifier to set
	 */
	public void setClassifier(String classifier) {
		this.classifier = classifier;
	}

	/**
	 * Sets the type of the Artifact
	 * 
	 * @param type the type of the Artifact
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * Gets the type of the Artifact
	 * 
	 * @return the Artifact type
	 */
	public String getType() {
		return type;
	}

	/**
	 * Gets the optional state
	 * 
	 * @return the optional state
	 */
	public boolean isOptional() {
		return optional;
	}

	/**
	 * Sets the optional state
	 * 
	 * @param optional the optional state
	 */
	public void setOptional(boolean optional) {
		this.optional = optional;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy