Package com.atlassian.bamboo.plan
Class PlanKeys
- java.lang.Object
-
- com.atlassian.bamboo.plan.PlanKeys
-
@PublicApi public final class PlanKeys extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static com.google.common.base.Function<PlanKey,PlanKey>
CHAIN_KEY_FROM_JOB_KEY
static com.google.common.base.Function<PlanKey,String>
PARTIAL_JOB_KEY_FROM_JOB_KEY
static Comparator<PlanKey>
PLAN_KEY_COMPARATOR
static com.google.common.base.Function<? super PlanResultKey,? extends PlanResultKey>
REMOVE_DELETION_MARKER
static char
SEP
static com.google.common.base.Function<PlanKey,String>
SHORT_KEY_FROM_PLAN_KEY
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PlanKey
asDeletedPlanKey(@NotNull PlanKey planKey)
static PlanKey
asNonDeletedPlanKey(@NotNull PlanKey planKey)
static void
assertSafeKey(String key)
static @NotNull PlanKey
getChainKeyFromJobKey(@NotNull PlanKey jobKey)
static @Nullable PlanKey
getChainKeyIfJobKey(@NotNull PlanKey jobKey)
static @NotNull PlanResultKey
getChainResultKey(@NotNull PlanResultKey planResultKey)
Creates a chain result key from job result key.static @NotNull PlanKey
getJobKey(@NotNull PlanKey chainPlanKey, @NotNull String jobKey)
static Optional<Long>
getNumberSuffixFromBranch(@NotNull PlanKey chainKey, @NotNull PlanKey branchKey)
Extract numerical branch suffixstatic String
getPartialJobKey(PlanKey jobKey)
Return a partial job key from a full job key, e.g.static PlanKey
getPlanKey(@NotNull com.atlassian.bamboo.specs.api.model.plan.PlanIdentifierProperties planIdentifier)
Creates aPlanKey
fromPlanIdentifierProperties
static PlanKey
getPlanKey(@NotNull com.atlassian.bamboo.specs.api.model.plan.PlanProperties planProperties)
Creates aPlanKey
from PlanPropertiesstatic @NotNull PlanKey
getPlanKey(@NotNull String planKey)
Creates aPlanKey
from its string form 'BAM-BOO' or from the result key form 'BAM-BOO-123'static PlanKey
getPlanKey(@NotNull String projectKey, @NotNull String buildKey)
Creates aPlanKey
from project key and build keystatic PlanKey
getPlanKey(@NotNull String projectKey, @Nullable String chainKey, @NotNull String buildKey)
Creates aPlanKey
from project key, parent chain key and build keystatic PlanKey
getPlanKey(com.atlassian.bamboo.specs.api.builders.plan.PlanIdentifier planIdentifier)
Creates aPlanKey
fromPlanIdentifier
static @NotNull String
getPlanKeyPart(@NotNull PlanKey planKey)
Returns plan key part for givenPlanKey
static @Nullable String
getPlanKeyPart(@NotNull PlanResultKey planResultKey)
Returns plan key part for givenPlanResultKey
static PlanResultKey
getPlanResultKey(@NotNull String planKey, int buildNumber)
Creates aPlanResultKey
from the given planKey and buildNumberstatic PlanResultKey
getPlanResultKey(PlanKey planKey, int buildNumber)
Creates aPlanResultKey
from the givenPlanKey
and buildNumberstatic PlanResultKey
getPlanResultKey(String planResultKey)
Creates aPlanResultKey
from its string form 'BAM-BOO-123'static @NotNull String
getProjectKeyPart(@NotNull PlanKey planKey)
Returns project key part for givenPlanKey
static @Nullable String
getProjectKeyPart(@NotNull PlanResultKey planResultKey)
Returns project key part for givenPlanResultKey
static String
getShortKeyFromPlanKey(PlanKey planKey)
Return a last part of the plan key, e.g PROJ-CHAIN would reduce CHAIN and PROJ-CHAIN-HOB would return JOBstatic boolean
isChainKey(@NotNull PlanKey planKey)
static boolean
isJobKey(@NotNull PlanKey planKey)
static boolean
isJobResultKey(@NotNull PlanResultKey planResultKey)
Checks ifPlanResultKey
represents a result ofJob
static boolean
isPlanKey(@NotNull String planKey)
static boolean
isPlanResultKey(String planResultKey)
static PlanKey
updatePlanKeyInBranchKey(@NotNull PlanKey branchKey, @NotNull PlanKey originalPlanKey, @NotNull PlanKey newPlanKey)
Update plan key part in branch key
-
-
-
Field Detail
-
SEP
public static final char SEP
- See Also:
- Constant Field Values
-
REMOVE_DELETION_MARKER
public static com.google.common.base.Function<? super PlanResultKey,? extends PlanResultKey> REMOVE_DELETION_MARKER
-
CHAIN_KEY_FROM_JOB_KEY
public static final com.google.common.base.Function<PlanKey,PlanKey> CHAIN_KEY_FROM_JOB_KEY
-
PARTIAL_JOB_KEY_FROM_JOB_KEY
public static final com.google.common.base.Function<PlanKey,String> PARTIAL_JOB_KEY_FROM_JOB_KEY
-
PLAN_KEY_COMPARATOR
public static final Comparator<PlanKey> PLAN_KEY_COMPARATOR
-
-
Method Detail
-
isChainKey
public static boolean isChainKey(@NotNull @NotNull PlanKey planKey)
- Parameters:
planKey
-- Returns:
- isChainKey
-
isJobKey
public static boolean isJobKey(@NotNull @NotNull PlanKey planKey)
- Parameters:
planKey
-- Returns:
- isJobKey
-
isJobResultKey
public static boolean isJobResultKey(@NotNull @NotNull PlanResultKey planResultKey)
Checks ifPlanResultKey
represents a result ofJob
- Parameters:
planResultKey
-- Returns:
- isJobResultKey
-
getPlanKey
public static PlanKey getPlanKey(@NotNull @NotNull String projectKey, @NotNull @NotNull String buildKey)
Creates aPlanKey
from project key and build key- Parameters:
projectKey
-buildKey
-- Returns:
- key
-
getPlanKey
public static PlanKey getPlanKey(@NotNull @NotNull com.atlassian.bamboo.specs.api.model.plan.PlanProperties planProperties)
Creates aPlanKey
from PlanProperties- Parameters:
planProperties
-- Returns:
- key
-
getPlanKey
public static PlanKey getPlanKey(@NotNull com.atlassian.bamboo.specs.api.builders.plan.PlanIdentifier planIdentifier)
Creates aPlanKey
fromPlanIdentifier
- Parameters:
planIdentifier
-- Returns:
- key
-
getPlanKey
public static PlanKey getPlanKey(@NotNull @NotNull com.atlassian.bamboo.specs.api.model.plan.PlanIdentifierProperties planIdentifier)
Creates aPlanKey
fromPlanIdentifierProperties
- Parameters:
planIdentifier
-- Returns:
- key
-
getProjectKeyPart
@NotNull public static @NotNull String getProjectKeyPart(@NotNull @NotNull PlanKey planKey)
Returns project key part for givenPlanKey
- Parameters:
planKey
-- Returns:
- project key
-
getProjectKeyPart
@Nullable public static @Nullable String getProjectKeyPart(@NotNull @NotNull PlanResultKey planResultKey)
Returns project key part for givenPlanResultKey
- Parameters:
planResultKey
-- Returns:
- project key
-
getPlanKeyPart
@NotNull public static @NotNull String getPlanKeyPart(@NotNull @NotNull PlanKey planKey)
Returns plan key part for givenPlanKey
- Parameters:
planKey
-- Returns:
- project key
-
getPlanKeyPart
@Nullable public static @Nullable String getPlanKeyPart(@NotNull @NotNull PlanResultKey planResultKey)
Returns plan key part for givenPlanResultKey
- Parameters:
planResultKey
-- Returns:
- project key
-
getJobKey
@NotNull public static @NotNull PlanKey getJobKey(@NotNull @NotNull PlanKey chainPlanKey, @NotNull @NotNull String jobKey)
Joins the aChain
key and a jobKey part to create a JobPlanKey
For example, BAM-REL and UNIT becomes BAM-REL-UNIT- Parameters:
chainPlanKey
-jobKey
-- Returns:
- planKey
-
getChainKeyFromJobKey
@NotNull public static @NotNull PlanKey getChainKeyFromJobKey(@NotNull @NotNull PlanKey jobKey)
Extracts aChain
key from a jobKey and creates newPlanKey
For example, BAM-REL-UNIT becomes BAM-REL- Parameters:
jobKey
-- Returns:
- chainKey
- Throws:
IllegalArgumentException
- if the argument has incorrect format.
-
getChainKeyIfJobKey
@Nullable public static @Nullable PlanKey getChainKeyIfJobKey(@NotNull @NotNull PlanKey jobKey)
Extracts aChain
key from a jobKey and creates newPlanKey
For example, BAM-REL-UNIT becomes BAM-REL Returns a Chain key if the passed in key is a Job key, otherwise a null is returned- Parameters:
jobKey
-- Returns:
- chainKey
-
getPlanKey
public static PlanKey getPlanKey(@NotNull @NotNull String projectKey, @Nullable @Nullable String chainKey, @NotNull @NotNull String buildKey)
Creates aPlanKey
from project key, parent chain key and build key- Parameters:
projectKey
-chainKey
- - if empty a key for top level plan is createdbuildKey
-- Returns:
- key
-
getPlanKey
@NotNull public static @NotNull PlanKey getPlanKey(@NotNull @NotNull String planKey)
Creates aPlanKey
from its string form 'BAM-BOO' or from the result key form 'BAM-BOO-123'- Parameters:
planKey
-- Returns:
- key
- Throws:
IllegalArgumentException
- if key could not be parsed
-
isPlanKey
public static boolean isPlanKey(@NotNull @NotNull String planKey)
-
getPlanResultKey
public static PlanResultKey getPlanResultKey(String planResultKey)
Creates aPlanResultKey
from its string form 'BAM-BOO-123'- Parameters:
planResultKey
-- Returns:
- key
- Throws:
IllegalArgumentException
- if key could not be parsed
-
getPlanResultKey
public static PlanResultKey getPlanResultKey(@NotNull @NotNull String planKey, int buildNumber)
Creates aPlanResultKey
from the given planKey and buildNumber- Parameters:
planKey
-buildNumber
-- Returns:
- key
- Throws:
IllegalArgumentException
- if key could not be parsed
-
getPlanResultKey
public static PlanResultKey getPlanResultKey(PlanKey planKey, int buildNumber)
Creates aPlanResultKey
from the givenPlanKey
and buildNumber- Parameters:
planKey
-buildNumber
-- Returns:
- planResultKey
-
getChainResultKey
@NotNull public static @NotNull PlanResultKey getChainResultKey(@NotNull @NotNull PlanResultKey planResultKey)
Creates a chain result key from job result key. E.g. BAM-BOO-N-1 will return BAM-BOO-1- Parameters:
planResultKey
- the job result key to convert- Returns:
- chain result key
-
getPartialJobKey
public static String getPartialJobKey(PlanKey jobKey)
Return a partial job key from a full job key, e.g. PROJ-CHAIN-JOB would return JOB.- Parameters:
jobKey
- a full job key- Returns:
- partial job key
-
getShortKeyFromPlanKey
public static String getShortKeyFromPlanKey(PlanKey planKey)
Return a last part of the plan key, e.g PROJ-CHAIN would reduce CHAIN and PROJ-CHAIN-HOB would return JOB- Parameters:
planKey
- a full plan key- Returns:
- short plan key
-
assertSafeKey
public static void assertSafeKey(String key)
-
updatePlanKeyInBranchKey
public static PlanKey updatePlanKeyInBranchKey(@NotNull @NotNull PlanKey branchKey, @NotNull @NotNull PlanKey originalPlanKey, @NotNull @NotNull PlanKey newPlanKey)
Update plan key part in branch key- Parameters:
branchKey
- branch key to be alteredoriginalPlanKey
- original plan keynewPlanKey
- new plan key- Returns:
- updated plan key or the original branchKey argument when it didn't match originalPlanKey
-
getNumberSuffixFromBranch
public static Optional<Long> getNumberSuffixFromBranch(@NotNull @NotNull PlanKey chainKey, @NotNull @NotNull PlanKey branchKey)
Extract numerical branch suffix- Parameters:
chainKey
- chain keybranchKey
- branch key- Returns:
- Long value of branch suffix or empty Option
- Throws:
IllegalArgumentException
- if the branch key doesn't start with chain keyNumberFormatException
- if the branch suffix is not proper numerical value
-
isPlanResultKey
public static boolean isPlanResultKey(String planResultKey)
-
-