Use Optional.ofNullable instead of a if statement

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-04-07 13:00:39 +02:00
parent fdee152885
commit c069b904b2
4 changed files with 7 additions and 8 deletions

View File

@@ -86,7 +86,7 @@ public class ArtifactUploadState implements ManagmentEntityState<Long>, Serializ
* @return the selectedBaseSwModuleId
*/
public Optional<Long> getSelectedBaseSwModuleId() {
return selectedBaseSwModuleId != null ? Optional.of(selectedBaseSwModuleId) : Optional.empty();
return Optional.ofNullable(selectedBaseSwModuleId);
}
/**
@@ -179,7 +179,7 @@ public class ArtifactUploadState implements ManagmentEntityState<Long>, Serializ
}
public Optional<SoftwareModule> getSelectedBaseSoftwareModule() {
return selectedBaseSoftwareModule == null ? Optional.empty() : Optional.of(selectedBaseSoftwareModule);
return Optional.ofNullable(selectedBaseSoftwareModule);
}
public void setSelectedBaseSoftwareModule(final SoftwareModule selectedBaseSoftwareModule) {

View File

@@ -24,5 +24,4 @@ public abstract class AbstractNamedVersionedEntityTableDetailsLayout<T extends N
protected String getName() {
return HawkbitCommonUtil.getFormattedNameVersion(selectedBaseEntity.getName(), selectedBaseEntity.getVersion());
}
}

View File

@@ -102,14 +102,14 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
* @return the slectedDistributions
*/
public Optional<Set<DistributionSetIdName>> getSelectedDistributions() {
return selectedDistributions == null ? Optional.empty() : Optional.of(selectedDistributions);
return Optional.ofNullable(selectedDistributions);
}
/**
* @return the lastSelectedDistribution
*/
public Optional<DistributionSetIdName> getLastSelectedDistribution() {
return lastSelectedDistribution == null ? Optional.empty() : Optional.of(lastSelectedDistribution);
return Optional.ofNullable(lastSelectedDistribution);
}
@Override
@@ -139,7 +139,7 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
* @return the selectedBaseSwModuleId
*/
public Optional<Long> getSelectedBaseSwModuleId() {
return selectedBaseSwModuleId != null ? Optional.of(selectedBaseSwModuleId) : Optional.empty();
return Optional.ofNullable(selectedBaseSwModuleId);
}
/**

View File

@@ -171,7 +171,7 @@ public class ManagementUIState implements ManagmentEntityState<DistributionSetId
}
public Optional<Set<TargetIdName>> getSelectedTargetIdName() {
return selectedTargetIdName == null ? Optional.empty() : Optional.of(selectedTargetIdName);
return Optional.ofNullable(selectedTargetIdName);
}
public void setSelectedTargetIdName(final Set<TargetIdName> selectedTargetIdName) {
@@ -279,7 +279,7 @@ public class ManagementUIState implements ManagmentEntityState<DistributionSetId
}
public Optional<Set<DistributionSetIdName>> getSelectedDsIdName() {
return selectedDsIdName == null ? Optional.empty() : Optional.of(selectedDsIdName);
return Optional.ofNullable(selectedDsIdName);
}
/**