com.atlassian.bamboo.plan
Class PlanKeys

java.lang.Object
  extended by com.atlassian.bamboo.plan.PlanKeys

@PublicApi
public final class PlanKeys
extends Object

Method for producing PlanKeys and PlanResultKeys from a String


Field Summary
static com.google.common.base.Function<PlanKey,PlanKey> CHAIN_KEY_FROM_JOB_KEY
           
static com.google.common.base.Function<? super PlanResultKey,? extends PlanResultKey> chainResultKeyFromJobResultKey
           
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<PlanKey,String> planKeyToKey
           
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
static PlanKey asDeletedPlanKey(PlanKey planKey)
           
static PlanKey asNonDeletedPlanKey(PlanKey planKey)
           
static void assertSafeKey(String key)
           
static com.atlassian.fugue.Option<Long> getBranchNumberSuffix(PlanKey chainKey, PlanKey branchKey)
          Extract numerical branch suffix
static PlanKey getChainKeyFromJobKey(PlanKey jobKey)
          Extracts a Chain key from a jobKey and creates new PlanKey For example, BAM-REL-UNIT becomes BAM-REL
static PlanKey getChainKeyIfJobKey(PlanKey jobKey)
          Extracts a Chain key from a jobKey and creates new PlanKey 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
static PlanResultKey getChainResultKey(PlanResultKey planResultKey)
          Creates a chain result key from job result key.
static PlanKey getJobKey(PlanKey chainPlanKey, String jobKey)
          Joins the a Chain key and a jobKey part to create a Job PlanKey For example, BAM-REL and UNIT becomes BAM-REL-UNIT
static String getPartialJobKey(PlanKey jobKey)
          Return a partial job key from a full job key, e.g.
static PlanKey getPlanKey(String planKey)
          Creates a PlanKey from its string form 'BAM-BOO' or from the result key form 'BAM-BOO-123'
static PlanKey getPlanKey(String projectKey, String buildKey)
          Creates a PlanKey from project key and build key
static PlanKey getPlanKey(String projectKey, String chainKey, String buildKey)
          Creates a PlanKey from project key, parent chain key and build key
static String getPlanKeyPart(PlanKey planKey)
          Returns plan key part for given PlanKey
static String getPlanKeyPart(PlanResultKey planResultKey)
          Returns plan key part for given PlanResultKey
static PlanResultKey getPlanResultKey(PlanKey planKey, int buildNumber)
          Creates a PlanResultKey from the given PlanKey and buildNumber
static PlanResultKey getPlanResultKey(String planResultKey)
          Creates a PlanResultKey from its string form 'BAM-BOO-123'
static PlanResultKey getPlanResultKey(String planKey, int buildNumber)
          Creates a PlanResultKey from the given planKey and buildNumber
static String getProjectKeyPart(PlanKey planKey)
          Returns project key part for given PlanKey
static String getProjectKeyPart(PlanResultKey planResultKey)
          Returns project key part for given PlanResultKey
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
static boolean isChainKey(PlanKey planKey)
          Checks if PlanKey represents a Chain
static boolean isJobKey(PlanKey planKey)
          Checks if PlanKey represents a Job
static com.google.common.base.Function<PlanIdentifier,PlanKey> planKeyFromPlan()
           
static com.google.common.base.Function<PlanResultKey,PlanKey> planKeyFromPlanResultKey()
           
static com.google.common.base.Function<String,PlanKey> planKeyFromString()
           
static com.google.common.base.Function<PlanResultKey,String> planKeyStringFromPlanResultKey()
           
static com.google.common.base.Function<PlanKey,String> planKeyToString()
           
static com.google.common.base.Function<String,PlanResultKey> planResultKeyFromString()
           
static PlanKey updatePlanKeyInBranchKey(PlanKey branchKey, PlanKey originalPlanKey, PlanKey newPlanKey)
          Update plan key part in branch key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

planKeyToKey

public static com.google.common.base.Function<PlanKey,String> planKeyToKey

chainResultKeyFromJobResultKey

public static com.google.common.base.Function<? super PlanResultKey,? extends PlanResultKey> chainResultKeyFromJobResultKey

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

SHORT_KEY_FROM_PLAN_KEY

public static final com.google.common.base.Function<PlanKey,String> SHORT_KEY_FROM_PLAN_KEY
Method Detail

planKeyFromPlanResultKey

public static com.google.common.base.Function<PlanResultKey,PlanKey> planKeyFromPlanResultKey()

planKeyStringFromPlanResultKey

public static com.google.common.base.Function<PlanResultKey,String> planKeyStringFromPlanResultKey()

planKeyFromString

public static com.google.common.base.Function<String,PlanKey> planKeyFromString()

planResultKeyFromString

public static com.google.common.base.Function<String,PlanResultKey> planResultKeyFromString()

planKeyToString

public static com.google.common.base.Function<PlanKey,String> planKeyToString()

planKeyFromPlan

public static com.google.common.base.Function<PlanIdentifier,PlanKey> planKeyFromPlan()

isChainKey

public static boolean isChainKey(@NotNull
                                 PlanKey planKey)
Checks if PlanKey represents a Chain

Parameters:
planKey -
Returns:
isChainKey

isJobKey

public static boolean isJobKey(@NotNull
                               PlanKey planKey)
Checks if PlanKey represents a Job

Parameters:
planKey -
Returns:
isJobKey

getPlanKey

public static PlanKey getPlanKey(@NotNull
                                 String projectKey,
                                 @NotNull
                                 String buildKey)
Creates a PlanKey from project key and build key

Parameters:
projectKey -
buildKey -
Returns:
key

getProjectKeyPart

@Nullable
public static String getProjectKeyPart(@NotNull
                                                PlanKey planKey)
Returns project key part for given PlanKey

Parameters:
planKey -
Returns:
project key

getProjectKeyPart

@Nullable
public static String getProjectKeyPart(@NotNull
                                                PlanResultKey planResultKey)
Returns project key part for given PlanResultKey

Parameters:
planResultKey -
Returns:
project key

getPlanKeyPart

@NotNull
public static String getPlanKeyPart(@NotNull
                                            PlanKey planKey)
Returns plan key part for given PlanKey

Parameters:
planKey -
Returns:
project key

getPlanKeyPart

@Nullable
public static String getPlanKeyPart(@NotNull
                                             PlanResultKey planResultKey)
Returns plan key part for given PlanResultKey

Parameters:
planResultKey -
Returns:
project key

getJobKey

@NotNull
public static PlanKey getJobKey(@NotNull
                                        PlanKey chainPlanKey,
                                        @NotNull
                                        String jobKey)
Joins the a Chain key and a jobKey part to create a Job PlanKey For example, BAM-REL and UNIT becomes BAM-REL-UNIT

Parameters:
chainPlanKey -
jobKey -
Returns:
planKey

getChainKeyFromJobKey

@NotNull
public static PlanKey getChainKeyFromJobKey(@NotNull
                                                    PlanKey jobKey)
Extracts a Chain key from a jobKey and creates new PlanKey For example, BAM-REL-UNIT becomes BAM-REL

Parameters:
jobKey -
Returns:
chainKey
Throws:
IllegalArgumentException - if the argument has incorrect format.

getChainKeyIfJobKey

@Nullable
public static PlanKey getChainKeyIfJobKey(@NotNull
                                                   PlanKey jobKey)
Extracts a Chain key from a jobKey and creates new PlanKey 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
                                 String projectKey,
                                 @Nullable
                                 String chainKey,
                                 @NotNull
                                 String buildKey)
Creates a PlanKey from project key, parent chain key and build key

Parameters:
projectKey -
chainKey - - if empty a key for top level plan is created
buildKey -
Returns:
key

getPlanKey

@NotNull
public static PlanKey getPlanKey(@NotNull
                                         String planKey)
Creates a PlanKey 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

getPlanResultKey

public static PlanResultKey getPlanResultKey(String planResultKey)
Creates a PlanResultKey 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
                                             String planKey,
                                             int buildNumber)
Creates a PlanResultKey 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 a PlanResultKey from the given PlanKey and buildNumber

Parameters:
planKey -
buildNumber -
Returns:
planResultKey

getChainResultKey

@NotNull
public static PlanResultKey getChainResultKey(@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
                                               PlanKey branchKey,
                                               @NotNull
                                               PlanKey originalPlanKey,
                                               @NotNull
                                               PlanKey newPlanKey)
Update plan key part in branch key

Parameters:
branchKey - branch key to be altered
originalPlanKey - original plan key
newPlanKey - new plan key
Returns:
updated plan key or the original branchKey argument when it didn't match originalPlanKey

getBranchNumberSuffix

public static com.atlassian.fugue.Option<Long> getBranchNumberSuffix(@NotNull
                                                                     PlanKey chainKey,
                                                                     @NotNull
                                                                     PlanKey branchKey)
Extract numerical branch suffix

Parameters:
chainKey - chain key
branchKey - branch key
Returns:
Long value of branch suffix or empty Option
Throws:
IllegalArgumentException - if the branch key doesn't start with chain key
NumberFormatException - if the branch suffix is not proper numerical value

asDeletedPlanKey

public static PlanKey asDeletedPlanKey(@NotNull
                                       PlanKey planKey)

asNonDeletedPlanKey

public static PlanKey asNonDeletedPlanKey(@NotNull
                                          PlanKey planKey)


Copyright © 2015 Atlassian Software Systems Pty Ltd. All rights reserved.