Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
package org.eclipse.hawkbit.mgmt.client.resource.builder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
Expand Down Expand Up @@ -62,8 +62,8 @@ public DistributionSetTypeBuilder description(final String description) {

/**
* @param softwareModuleTypeIds
* the IDs of the software module types which should be mandatory
* for the distribution set type
* the IDs of the software module types which should be mandatory for
* the distribution set type
* @return the builder itself
*/
public DistributionSetTypeBuilder mandatorymodules(final Long... softwareModuleTypeIds) {
Expand All @@ -78,8 +78,8 @@ public DistributionSetTypeBuilder mandatorymodules(final Long... softwareModuleT
/**
*
* @param softwareModuleTypeIds
* the IDs of the software module types which should be optional
* for the distribution set type
* the IDs of the software module types which should be optional for
* the distribution set type
* @return the builder itself
*/
public DistributionSetTypeBuilder optionalmodules(final Long... softwareModuleTypeIds) {
Expand All @@ -93,44 +93,40 @@ public DistributionSetTypeBuilder optionalmodules(final Long... softwareModuleTy

/**
* Builds a list with a single entry of
* {@link MgmtDistributionSetTypeRequestBodyPost} which can directly be used
* in the RESTful-API.
* {@link MgmtDistributionSetTypeRequestBodyPost} which can directly be used in
* the RESTful-API.
*
* @return a single entry list of
* {@link MgmtDistributionSetTypeRequestBodyPost}
* @return a single entry list of {@link MgmtDistributionSetTypeRequestBodyPost}
*/
public List<MgmtDistributionSetTypeRequestBodyPost> build() {
return Arrays.asList(doBuild(""));
return Collections.singletonList(doBuild(key, name));
}

/**
* Builds a list of multiple {@link MgmtDistributionSetTypeRequestBodyPost}
* to create multiple distribution set types at once. An increasing number
* will be added to the name and key of the distribution set type. The
* optional and mandatory software module types will remain the same.
* Builds a list of multiple {@link MgmtDistributionSetTypeRequestBodyPost} to
* create multiple distribution set types at once. An increasing number will be
* added to the name and key of the distribution set type. The optional and
* mandatory software module types will remain the same.
*
* @param count
* the amount of distribution sets type body which should be
* created
* the amount of distribution sets type body which should be created
* @return a list of {@link MgmtDistributionSetTypeRequestBodyPost}
*/
public List<MgmtDistributionSetTypeRequestBodyPost> buildAsList(final int count) {
final List<MgmtDistributionSetTypeRequestBodyPost> bodyList = new ArrayList<>();
for (int index = 0; index < count; index++) {
bodyList.add(doBuild(String.valueOf(index)));
bodyList.add(doBuild(key + index, name + index));
}
return bodyList;

}

private MgmtDistributionSetTypeRequestBodyPost doBuild(final String suffix) {
private MgmtDistributionSetTypeRequestBodyPost doBuild(final String key, final String name) {
final MgmtDistributionSetTypeRequestBodyPost body = new MgmtDistributionSetTypeRequestBodyPost();
body.setKey(key + suffix);
body.setName(name + suffix);
body.setKey(key);
body.setName(name);
body.setDescription(description);
body.setMandatorymodules(mandatorymodules);
body.setOptionalmodules(optionalmodules);
return body;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
package org.eclipse.hawkbit.mgmt.client.resource.builder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost;
Expand Down Expand Up @@ -71,41 +71,38 @@ public SoftwareModuleTypeBuilder maxAssignments(final int maxAssignments) {

/**
* Builds a list with a single entry of
* {@link MgmtSoftwareModuleTypeRequestBodyPost} which can directly be used
* in the RESTful-API.
* {@link MgmtSoftwareModuleTypeRequestBodyPost} which can directly be used in
* the RESTful-API.
*
* @return a single entry list of
* {@link MgmtSoftwareModuleTypeRequestBodyPost}
* @return a single entry list of {@link MgmtSoftwareModuleTypeRequestBodyPost}
*/
public List<MgmtSoftwareModuleTypeRequestBodyPost> build() {
return Arrays.asList(doBuild(""));
return Collections.singletonList(doBuild(key, name));
}

/**
* Builds a list of multiple {@link MgmtSoftwareModuleTypeRequestBodyPost}
* to create multiple software module types at once. An increasing number
* will be added to the name and key of the software module type.
* Builds a list of multiple {@link MgmtSoftwareModuleTypeRequestBodyPost} to
* create multiple software module types at once. An increasing number will be
* added to the name and key of the software module type.
*
* @param count
* the amount of software module type bodies which should be
* created
* the amount of software module type bodies which should be created
* @return a list of {@link MgmtSoftwareModuleTypeRequestBodyPost}
*/
public List<MgmtSoftwareModuleTypeRequestBodyPost> buildAsList(final int count) {
final List<MgmtSoftwareModuleTypeRequestBodyPost> bodyList = new ArrayList<>();
for (int index = 0; index < count; index++) {
bodyList.add(doBuild(String.valueOf(index)));
bodyList.add(doBuild(key + index, name + index));
}
return bodyList;
}

private MgmtSoftwareModuleTypeRequestBodyPost doBuild(final String suffix) {
private MgmtSoftwareModuleTypeRequestBodyPost doBuild(final String key, final String name) {
final MgmtSoftwareModuleTypeRequestBodyPost body = new MgmtSoftwareModuleTypeRequestBodyPost();
body.setKey(key + suffix);
body.setName(name + suffix);
body.setKey(key);
body.setName(name);
body.setDescription(description);
body.setMaxAssignments(maxAssignments);
return body;
}

}