Fix SonarQube issues (2) (#2205)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -19,4 +19,8 @@ public abstract class AbstractBaseEntityBuilder implements Identifiable<Long> {
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
static String strip(final String value) {
|
||||
return value == null ? null : value.strip();
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ package org.eclipse.hawkbit.repository.builder;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.eclipse.hawkbit.repository.ValidString;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Create and update builder DTO.
|
||||
@@ -25,6 +25,7 @@ public abstract class AbstractDistributionSetUpdateCreate<T> extends AbstractNam
|
||||
@ValidString
|
||||
protected String version;
|
||||
protected Boolean requiredMigrationStep;
|
||||
@Getter
|
||||
protected Collection<Long> modules;
|
||||
|
||||
public T modules(final Collection<Long> modules) {
|
||||
@@ -32,10 +33,6 @@ public abstract class AbstractDistributionSetUpdateCreate<T> extends AbstractNam
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public Collection<Long> getModules() {
|
||||
return modules;
|
||||
}
|
||||
|
||||
public T requiredMigrationStep(final Boolean requiredMigrationStep) {
|
||||
this.requiredMigrationStep = requiredMigrationStep;
|
||||
return (T) this;
|
||||
@@ -46,7 +43,7 @@ public abstract class AbstractDistributionSetUpdateCreate<T> extends AbstractNam
|
||||
}
|
||||
|
||||
public T version(final String version) {
|
||||
this.version = StringUtils.trimWhitespace(version);
|
||||
this.version = strip(version);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import java.util.Optional;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.eclipse.hawkbit.repository.ValidString;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Create and update builder DTO.
|
||||
@@ -29,12 +28,12 @@ public abstract class AbstractMetadataUpdateCreate<T> {
|
||||
protected String value;
|
||||
|
||||
public T key(final String key) {
|
||||
this.key = StringUtils.trimWhitespace(key);
|
||||
this.key = AbstractBaseEntityBuilder.strip(key);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T value(final String value) {
|
||||
this.value = StringUtils.trimWhitespace(value);
|
||||
this.value = AbstractBaseEntityBuilder.strip(value);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.repository.builder;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.hawkbit.repository.ValidString;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
public abstract class AbstractNamedEntityBuilder<T> extends AbstractBaseEntityBuilder {
|
||||
|
||||
@@ -22,12 +21,12 @@ public abstract class AbstractNamedEntityBuilder<T> extends AbstractBaseEntityBu
|
||||
protected String description;
|
||||
|
||||
public T name(final String name) {
|
||||
this.name = StringUtils.trimWhitespace(name);
|
||||
this.name = AbstractBaseEntityBuilder.strip(name);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T description(final String description) {
|
||||
this.description = StringUtils.trimWhitespace(description);
|
||||
this.description = AbstractBaseEntityBuilder.strip(description);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository.builder;
|
||||
|
||||
import org.eclipse.hawkbit.repository.ValidString;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Create builder DTO.
|
||||
@@ -27,7 +26,7 @@ public abstract class AbstractRolloutGroupCreate<T> extends AbstractNamedEntityB
|
||||
protected boolean confirmationRequired;
|
||||
|
||||
public T targetFilterQuery(final String targetFilterQuery) {
|
||||
this.targetFilterQuery = StringUtils.trimWhitespace(targetFilterQuery);
|
||||
this.targetFilterQuery = AbstractBaseEntityBuilder.strip(targetFilterQuery);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.repository.builder;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.hawkbit.repository.ValidString;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Create and update builder DTO.
|
||||
@@ -29,7 +28,7 @@ public abstract class AbstractSoftwareModuleUpdateCreate<T> extends AbstractName
|
||||
protected String type;
|
||||
|
||||
public T type(final String type) {
|
||||
this.type = StringUtils.trimWhitespace(type);
|
||||
this.type = AbstractBaseEntityBuilder.strip(type);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -38,7 +37,7 @@ public abstract class AbstractSoftwareModuleUpdateCreate<T> extends AbstractName
|
||||
}
|
||||
|
||||
public T vendor(final String vendor) {
|
||||
this.vendor = StringUtils.trimWhitespace(vendor);
|
||||
this.vendor = AbstractBaseEntityBuilder.strip(vendor);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -47,7 +46,7 @@ public abstract class AbstractSoftwareModuleUpdateCreate<T> extends AbstractName
|
||||
}
|
||||
|
||||
public T version(final String version) {
|
||||
this.version = StringUtils.trimWhitespace(version);
|
||||
this.version = AbstractBaseEntityBuilder.strip(version);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class AbstractTagUpdateCreate<T> extends AbstractNamedEntityBuilder<T> {
|
||||
protected String colour;
|
||||
|
||||
public T colour(final String colour) {
|
||||
this.colour = StringUtils.trimWhitespace(colour);
|
||||
this.colour = AbstractBaseEntityBuilder.strip(colour);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.eclipse.hawkbit.repository.ValidString;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Create and update builder DTO.
|
||||
@@ -91,7 +90,7 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
|
||||
* @return this builder
|
||||
*/
|
||||
public T name(final String name) {
|
||||
this.name = StringUtils.trimWhitespace(name);
|
||||
this.name = AbstractBaseEntityBuilder.strip(name);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -106,7 +105,7 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
|
||||
* @return this builder
|
||||
*/
|
||||
public T query(final String query) {
|
||||
this.query = StringUtils.trimWhitespace(query);
|
||||
this.query = AbstractBaseEntityBuilder.strip(query);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import lombok.ToString;
|
||||
import org.eclipse.hawkbit.repository.ValidString;
|
||||
import org.eclipse.hawkbit.repository.exception.InvalidTargetAddressException;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Create and update builder DTO.
|
||||
@@ -37,7 +36,7 @@ public class AbstractTargetUpdateCreate<T> extends AbstractNamedEntityBuilder<T>
|
||||
protected Long targetTypeId;
|
||||
|
||||
protected AbstractTargetUpdateCreate(final String controllerId) {
|
||||
this.controllerId = StringUtils.trimWhitespace(controllerId);
|
||||
this.controllerId = AbstractBaseEntityBuilder.strip(controllerId);
|
||||
}
|
||||
|
||||
public T status(final TargetUpdateStatus status) {
|
||||
@@ -49,7 +48,7 @@ public class AbstractTargetUpdateCreate<T> extends AbstractNamedEntityBuilder<T>
|
||||
// check if this is a real URI
|
||||
if (address != null) {
|
||||
try {
|
||||
URI.create(StringUtils.trimWhitespace(address));
|
||||
URI.create(AbstractBaseEntityBuilder.strip(address));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
throw new InvalidTargetAddressException(
|
||||
"The given address " + address + " violates the RFC-2396 specification", e);
|
||||
@@ -60,7 +59,7 @@ public class AbstractTargetUpdateCreate<T> extends AbstractNamedEntityBuilder<T>
|
||||
}
|
||||
|
||||
public T securityToken(final String securityToken) {
|
||||
this.securityToken = StringUtils.trimWhitespace(securityToken);
|
||||
this.securityToken = AbstractBaseEntityBuilder.strip(securityToken);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -75,7 +74,7 @@ public class AbstractTargetUpdateCreate<T> extends AbstractNamedEntityBuilder<T>
|
||||
}
|
||||
|
||||
public TargetCreate controllerId(final String controllerId) {
|
||||
this.controllerId = StringUtils.trimWhitespace(controllerId);
|
||||
this.controllerId = AbstractBaseEntityBuilder.strip(controllerId);
|
||||
return (TargetCreate) this;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.repository.builder;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.hawkbit.repository.ValidString;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Create and update builder DTO.
|
||||
@@ -27,7 +26,7 @@ public abstract class AbstractTypeUpdateCreate<T> extends AbstractNamedEntityBui
|
||||
protected String key;
|
||||
|
||||
public T colour(final String colour) {
|
||||
this.colour = StringUtils.trimWhitespace(colour);
|
||||
this.colour = AbstractBaseEntityBuilder.strip(colour);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -36,7 +35,7 @@ public abstract class AbstractTypeUpdateCreate<T> extends AbstractNamedEntityBui
|
||||
}
|
||||
|
||||
public T key(final String key) {
|
||||
this.key = StringUtils.trimWhitespace(key);
|
||||
this.key = AbstractBaseEntityBuilder.strip(key);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user