![JAR search and dependency download from the Maven repository](/logo.png)
com.marvelution.maven.components.migration.manager.configuration.ParentProject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-migration-manager Show documentation
Show all versions of maven-migration-manager Show documentation
Maven 2.x Plexus Migration Manager Component used by the maven-migrator-plugin
The newest version!
/*
* 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.maven.components.migration.manager.configuration;
import org.codehaus.plexus.util.StringUtils;
/**
* Parent Project
*
* @author Mark Rekveld
*/
public class ParentProject {
/**
* The groupId of the parent
*/
private String groupId;
/**
* The artifactId of the parent
*/
private String artifactId;
/**
* The version of the parent
*/
private String version;
/**
* Constructor
*
* @param groupId the groupId of the parent project, may not be null
* @param artifactid the artifactId of the parent project, may not be null
* @param version the version of the parent project, may not be null
*/
public ParentProject(String groupId, String artifactid, String version) {
if (StringUtils.isEmpty(groupId) || StringUtils.isEmpty(artifactid) || StringUtils.isEmpty(version)) {
throw new IllegalArgumentException(
"ParentProject groupId, artifactId and version are required and may not be null");
}
this.groupId = groupId;
this.artifactId = artifactid;
this.version = version;
}
/**
* Gets the groupId of the Parent project
*
* @return the groupId
*/
public String getGroupId() {
return groupId;
}
/**
* Gets the artifactId of the Parent project
*
* @return the artifactId
*/
public String getArtifactId() {
return artifactId;
}
/**
* gets the version of the Parent project
*
* @return the version
*/
public String getVersion() {
return version;
}
/**
* Gets the management key for the parent project
*
* @return the management key in format groupId:artifactId:version
*/
public final String getManagementKey() {
return groupId + ":" + artifactId + ":" + version;
}
/**
* Create a {@link ParentProject} from a Management Key in format groupId:artifactId:version
*
* @param managementKey the management key
* @return the created {@link ParentProject}
*/
public static final ParentProject createParentProject(String managementKey) {
final String[] elements = managementKey.split(":");
if (elements.length != 3) {
throw new IllegalArgumentException(
"Invalid management key provided, key needs to be in format groupId:artifactId:version");
}
return new ParentProject(elements[0], elements[1], elements[2]);
}
/**
* {@inheritDoc}
*/
public boolean equals(Object otherProjectParent) {
if (otherProjectParent instanceof ParentProject) {
final ParentProject otherParent = (ParentProject) otherProjectParent;
return getManagementKey().equals(otherParent.getManagementKey());
}
return false;
}
/**
* {@inheritDoc}
*/
public int hashCode() {
return getManagementKey().hashCode();
}
/**
* {@inheritDoc}
*/
public String toString() {
return getManagementKey();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy