Class PlanHelper


  • public final class PlanHelper
    extends Object
    • Method Detail

      • isDivergentBranch

        public static boolean isDivergentBranch​(@NotNull
                                                @NotNull ImmutablePlan plan)
        Returns:
        true if plan is a plan branch of a job of a plan branch and plan branch is divergent
      • isDivergentBranch

        public static boolean isDivergentBranch​(@NotNull
                                                @NotNull ImmutableChain chain)
        Returns:
        true if plan is a plan branch of a job of a plan branch and plan branch is divergent
      • getCurrentStatus

        public static String getCurrentStatus​(@NotNull
                                              @NotNull ImmutablePlan plan)
      • getMasterPlan

        @NotNull
        public static @NotNull ImmutablePlan getMasterPlan​(@NotNull
                                                           @NotNull ImmutablePlan plan)
        Get master plan if plan has master or passed plan otherwise.
        Parameters:
        plan -
        Returns:
      • getMasterPlan

        @NotNull
        public static @NotNull ImmutableChain getMasterPlan​(@NotNull
                                                            @NotNull ImmutableChain plan)
        Get master plan if plan has master or passed plan otherwise.
        Parameters:
        plan -
        Returns:
      • getMasterPlan

        @NotNull
        public static @NotNull Chain getMasterPlan​(@NotNull
                                                   @NotNull Chain plan)
        Get master plan if plan has master or passed plan otherwise.
        Parameters:
        plan -
        Returns:
      • getMasterPlanKey

        @NotNull
        public static @NotNull PlanKey getMasterPlanKey​(@NotNull
                                                        @NotNull ImmutablePlan plan)
        Get planKey of master plan if plan has master or planKey of passed plan otherwise.
        Parameters:
        plan -
        Returns:
      • getBranchedImmutableJob

        public static ImmutableJob getBranchedImmutableJob​(ImmutableChain chainBranch,
                                                           ImmutableJob masterJob)
        Searches for a corresponding job in a branch.
        Parameters:
        chainBranch - branch where job has to be searched
        masterJob - job which is to be found in a branch
        Returns:
        ImmutableJob or null if not found
      • getConfigObject

        @Nullable
        public static <T> T getConfigObject​(@NotNull
                                            @NotNull ImmutablePlan plan,
                                            @NotNull
                                            @NotNull String key,
                                            @NotNull
                                            @NotNull Class<T> clazz)
      • getConfigObject

        @Nullable
        public static <T> T getConfigObject​(@NotNull
                                            @NotNull BuildDefinition planDefinition,
                                            @NotNull
                                            @NotNull String key,
                                            @NotNull
                                            @NotNull Class<T> clazz)
      • getPermissionPlanId

        public static long getPermissionPlanId​(ImmutablePlan plan)
      • getMasterAndBranchesKeys

        @NotNull
        public static @NotNull Set<PlanKey> getMasterAndBranchesKeys​(@NotNull
                                                                     @NotNull CachedPlanManager cachedPlanManager,
                                                                     @NotNull
                                                                     @NotNull PlanKey masterOrBranchKey)
        Get keys of all branches and master plan.
        Parameters:
        cachedPlanManager - cachedPlanManager bean
        masterOrBranchKey - key of either master plan or one of the branches in the family
        Returns:
        set of keys of all branches and master plan
      • getPlanKeysOfBranchesSharingConfiguration

        @NotNull
        public static @NotNull Set<PlanKey> getPlanKeysOfBranchesSharingConfiguration​(@NotNull
                                                                                      @NotNull CachedPlanManager cachedPlanManager,
                                                                                      @NotNull
                                                                                      @NotNull PlanKey masterOrBranchKey)
        Get keys of all branches (including master plan if applicable) that share the configuration. If the argumanet is a key of a master plan or any lightweight branch, the returned list contains key of the master plan and keys of all its lightweight branches. If the argument is a key of a divergent branch, the list containing that key only is returned.
        Parameters:
        cachedPlanManager - cachedPlanManager bean
        masterOrBranchKey - key of either master plan or one of the branches in the family
        Returns:
        set of keys of all lightweight branches and master plan
      • haveTheSameMaster

        public static boolean haveTheSameMaster​(@NotNull
                                                @NotNull CachedPlanManager cachedPlanManager,
                                                @NotNull
                                                @NotNull PlanKey masterOrBranchKeyA,
                                                @NotNull
                                                @NotNull PlanKey masterOrBranchKeyB)
      • haveTheSameMaster

        public static boolean haveTheSameMaster​(@NotNull
                                                @NotNull ImmutableChain masterOrBranchA,
                                                @NotNull
                                                @NotNull ImmutableChain masterOrBranchB)
      • hasMultipleBranches

        public static boolean hasMultipleBranches​(@NotNull
                                                  @NotNull CachedPlanManager cachedPlanManager,
                                                  @NotNull
                                                  @NotNull PlanKey planKey)
      • defaultRepositoryAsRootPredicate

        public static Predicate<ImmutableChain> defaultRepositoryAsRootPredicate​(long repositoryId)
        passes chains when the default plan repository definition points to root definition with given id