![JAR search and dependency download from the Maven repository](/logo.png)
com.marvelution.hudson.plugins.apiv2.cache.issue.IssueKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hudson-apiv2-plugin Show documentation
Show all versions of hudson-apiv2-plugin Show documentation
This plugin features a Wink REST API application.
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.hudson.plugins.apiv2.cache.issue;
import java.util.regex.Matcher;
import com.marvelution.hudson.plugins.apiv2.utils.JiraKeyUtils;
/**
* JIRA Issue Key object
*
* @author Mark Rekveld
*
* @since 4.4.0
*/
public class IssueKey {
private String project;
private int issue;
/**
* Constructor
*
* @param project
* @param issue
*/
public IssueKey(String project, int issue) {
this.project = project;
this.issue = issue;
}
/**
* Getter for project
*
* @return the project
*/
public String getProject() {
return project;
}
/**
* Getter for issue
*
* @return the issue
*/
public int getIssue() {
return issue;
}
/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof String) {
return toString().equalsIgnoreCase((String) obj);
} else {
return toString().equals(obj);
}
}
/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return toString().hashCode();
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return String.format("%1$s-%2$d", project, issue);
}
/**
* Get an {@link IssueKey} object from a given {@link String}
*
* @param issueKey the {@link String} to parse
* @return the {@link IssueKey}
* @throws IllegalArgumentException in case the given {@link String} is not a valid JIRA Issue Key
*/
public static IssueKey getIssueKey(String issueKey) {
if (JiraKeyUtils.isValidIssueKey(issueKey)) {
Matcher matcher = JiraKeyUtils.DEFAULT_JIRA_ISSUE_KEY_PATTERN.matcher(issueKey);
if (matcher.find()) {
return new IssueKey(matcher.group(2), Integer.parseInt(matcher.group(3)));
}
}
throw new IllegalArgumentException(issueKey + " is not a valid JIRA Issue Key");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy