Skip to content

Commit

Permalink
Make group of() private
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Jan 9, 2025
1 parent abf4d00 commit 73a48c0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions core/src/main/java/hudson/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
import jenkins.model.DetailFactory;
import jenkins.model.GlobalConfiguration;
import jenkins.model.GlobalConfigurationCategory;
import jenkins.model.Group;
import jenkins.model.DetailGroup;
import jenkins.model.Jenkins;
import jenkins.model.ModelObjectWithChildren;
import jenkins.model.ModelObjectWithContextMenu;
Expand Down Expand Up @@ -2596,20 +2596,20 @@ public static String generateItemId() {
* Returns a grouped list of Detail objects for the given Run
*/
@Restricted(NoExternalUse.class)
public static Map<Group, List<Detail>> getDetailsFor(Run<?, ?> run) {
public static Map<DetailGroup, List<Detail>> getDetailsFor(Run<?, ?> run) {
List<Detail> details = new ArrayList<>();

for (DetailFactory<Run> df : DetailFactory.factoriesFor(Run.class)) {
details.addAll(df.createFor(run));
}

Map<Group, List<Detail>> orderedMap = new TreeMap<>(Comparator.comparingInt(Group::getOrder));
Map<DetailGroup, List<Detail>> orderedMap = new TreeMap<>(Comparator.comparingInt(DetailGroup::getOrder));

for (Detail detail : details) {
orderedMap.computeIfAbsent(detail.getGroup(), k -> new ArrayList<>()).add(detail);
}

for (Map.Entry<Group, List<Detail>> entry : orderedMap.entrySet()) {
for (Map.Entry<DetailGroup, List<Detail>> entry : orderedMap.entrySet()) {
List<Detail> detailList = entry.getValue();
detailList.sort(Comparator.comparingInt(Detail::getOrder));
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/jenkins/model/Detail.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public Detail(Run<?, ?> object) {
/**
* @return the grouping of the detail
*/
public Group getGroup() {
return Group.GENERAL;
public DetailGroup getGroup() {
return DetailGroup.GENERAL;
}

/**
Expand Down
26 changes: 26 additions & 0 deletions core/src/main/java/jenkins/model/DetailGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package jenkins.model;

public class DetailGroup {

private final int order;

private DetailGroup(int order) {
if (order < 0) {
throw new RuntimeException("Orders cannot be less than 0");
}

this.order = order;
}

public static DetailGroup SCM = of(0);

public static DetailGroup GENERAL = of(Integer.MAX_VALUE);

private static DetailGroup of(int customOrder) {
return new DetailGroup(customOrder);
}

public int getOrder() {
return order;
}
}
26 changes: 0 additions & 26 deletions core/src/main/java/jenkins/model/Group.java

This file was deleted.

0 comments on commit 73a48c0

Please sign in to comment.