From 5f20066cff4a7b1d1e8ffcfb42cc0da0ddc3f058 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Fri, 5 Aug 2016 15:55:49 +0200 Subject: [PATCH] Fix sonar issue Signed-off-by: SirWayne --- .../hawkbit/artifact/FreePortFileWriter.java | 8 +- .../mgmt/rest/resource/MgmtSystemMapper.java | 4 +- .../test/matcher/BaseEntityMatcher.java | 2 +- .../security/SecurityContextTenantAware.java | 9 +- .../security/SystemSecurityContext.java | 8 +- .../ui/artifacts/upload/UploadLayout.java | 84 +++++++++---------- .../ui/colorpicker/ColorPickerConstants.java | 2 +- .../ui/colorpicker/ColorPickerHelper.java | 8 +- .../polling/DurationConfigField.java | 63 ++++++++++++-- 9 files changed, 121 insertions(+), 67 deletions(-) diff --git a/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/FreePortFileWriter.java b/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/FreePortFileWriter.java index 0e957d83a..b0bcc5b6e 100644 --- a/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/FreePortFileWriter.java +++ b/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/FreePortFileWriter.java @@ -12,6 +12,8 @@ import java.io.File; import java.net.InetSocketAddress; import java.net.ServerSocket; +import org.apache.commons.io.IOUtils; + /** * * Look for a free port. @@ -48,6 +50,7 @@ public class FreePortFileWriter { } boolean isFree(final int port) { + ServerSocket sock = null; try { final File portFile = new File(filePortPath + File.separator + port + ".port"); portFile.getParentFile().mkdirs(); @@ -55,19 +58,20 @@ public class FreePortFileWriter { return false; } boolean isFree = false; - final ServerSocket sock = new ServerSocket(); + sock = new ServerSocket(); sock.setReuseAddress(true); sock.bind(new InetSocketAddress(port)); if (portFile.createNewFile()) { portFile.deleteOnExit(); isFree = true; } - sock.close(); return isFree; // We rely on an exception thrown to determine availability or // not availability and don't want to log the exception. } catch (@SuppressWarnings({ "squid:S2221", "squid:S1166" }) final Exception e) { return false; + } finally { + IOUtils.closeQuietly(sock); } } diff --git a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemMapper.java b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemMapper.java index d3f78fad2..d0c8dfcc5 100644 --- a/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemMapper.java +++ b/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemMapper.java @@ -23,7 +23,7 @@ import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; * A mapper which maps repository model to RESTful model representation and * back. */ -public class MgmtSystemMapper { +public final class MgmtSystemMapper { private MgmtSystemMapper() { // Utility class @@ -51,6 +51,8 @@ public class MgmtSystemMapper { * maps a TenantConfigurationValue from the repository model to a * MgmtSystemTenantConfigurationValue, the RESTful model. * + * @param key + * the key * @param repoConfValue * configuration value as repository model * @return configuration value as RESTful model diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/matcher/BaseEntityMatcher.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/matcher/BaseEntityMatcher.java index cb3f5476f..c83ae8ad1 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/matcher/BaseEntityMatcher.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/matcher/BaseEntityMatcher.java @@ -17,7 +17,7 @@ import org.hamcrest.Matchers; /** * Matcher for {@link BaseEntity}. */ -public class BaseEntityMatcher { +public final class BaseEntityMatcher { private BaseEntityMatcher() { } diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityContextTenantAware.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityContextTenantAware.java index f2cfbbdbf..6e4ac7f8f 100644 --- a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityContextTenantAware.java +++ b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityContextTenantAware.java @@ -28,11 +28,6 @@ import org.springframework.security.core.context.SecurityContextImpl; */ public class SecurityContextTenantAware implements TenantAware { - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.tenancy.TenantAware#getCurrentTenantId() - */ @Override public String getCurrentTenant() { final SecurityContext context = SecurityContextHolder.getContext(); @@ -56,7 +51,7 @@ public class SecurityContextTenantAware implements TenantAware { } } - private SecurityContext buildSecurityContext(final String tenant) { + private static SecurityContext buildSecurityContext(final String tenant) { final SecurityContextImpl securityContext = new SecurityContextImpl(); securityContext.setAuthentication( new AuthenticationDelegate(SecurityContextHolder.getContext().getAuthentication(), tenant)); @@ -68,7 +63,7 @@ public class SecurityContextTenantAware implements TenantAware { * {@link Authentication} object except setting the details specifically for * a specific tenant. */ - private class AuthenticationDelegate implements Authentication { + private static final class AuthenticationDelegate implements Authentication { private static final long serialVersionUID = 1L; private final Authentication delegate; diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SystemSecurityContext.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SystemSecurityContext.java index 0e3863d97..4432fbb67 100644 --- a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SystemSecurityContext.java +++ b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SystemSecurityContext.java @@ -34,7 +34,7 @@ import com.google.common.base.Throwables; @Service public class SystemSecurityContext { - private static final Logger logger = LoggerFactory.getLogger(SystemSecurityContext.class); + private static final Logger LOG = LoggerFactory.getLogger(SystemSecurityContext.class); private final TenantAware tenantAware; @@ -96,7 +96,7 @@ public class SystemSecurityContext { public T runAsSystemAsTenant(final Callable callable, final String tenant) { final SecurityContext oldContext = SecurityContextHolder.getContext(); try { - logger.debug("entering system code execution"); + LOG.debug("entering system code execution"); return tenantAware.runAsTenant(tenant, () -> { try { setSystemContext(SecurityContextHolder.getContext()); @@ -110,7 +110,7 @@ public class SystemSecurityContext { } finally { SecurityContextHolder.setContext(oldContext); - logger.debug("leaving system code execution"); + LOG.debug("leaving system code execution"); } } @@ -136,7 +136,7 @@ public class SystemSecurityContext { * {@link SpringEvalExpressions#SYSTEM_ROLE} which is allowed to execute all * secured methods. */ - public static class SystemCodeAuthentication implements Authentication { + public static final class SystemCodeAuthentication implements Authentication { private static final long serialVersionUID = 1L; private static final List AUTHORITIES = Collections diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java index af02e917b..a7e5bd670 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java @@ -248,7 +248,7 @@ public class UploadLayout extends VerticalLayout { final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); // selected software module at the time of file drop is // considered for upload - SoftwareModule selectedSw = artifactUploadState.getSelectedBaseSoftwareModule().get(); + final SoftwareModule selectedSw = artifactUploadState.getSelectedBaseSoftwareModule().get(); // reset the flag hasDirectory = Boolean.FALSE; for (final Html5File file : files) { @@ -265,7 +265,7 @@ public class UploadLayout extends VerticalLayout { } } - private void processFile(final Html5File file, SoftwareModule selectedSw) { + private void processFile(final Html5File file, final SoftwareModule selectedSw) { if (!isDirectory(file)) { if (!checkForDuplicate(file.getFileName(), selectedSw)) { artifactUploadState.getNumberOfFileUploadsExpected().incrementAndGet(); @@ -276,7 +276,7 @@ public class UploadLayout extends VerticalLayout { } } - private StreamVariable createStreamVariable(final Html5File file, SoftwareModule selectedSw) { + private StreamVariable createStreamVariable(final Html5File file, final SoftwareModule selectedSw) { return new UploadHandler(file.getFileName(), file.getFileSize(), UploadLayout.this, spInfo.getMaxArtifactFileSize(), null, file.getType(), selectedSw); } @@ -366,11 +366,13 @@ public class UploadLayout extends VerticalLayout { * in case of upload errors */ OutputStream saveUploadedFileDetails(final String name, final long size, final String mimeType, - SoftwareModule selectedSw) { + final SoftwareModule selectedSw) { File tempFile = null; try { tempFile = File.createTempFile("spUiArtifactUpload", null); + // we return the outputstream so we cannot close it here + @SuppressWarnings("squid:S2095") final OutputStream out = new FileOutputStream(tempFile); final String currentBaseSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(selectedSw.getName(), @@ -445,8 +447,8 @@ public class UploadLayout extends VerticalLayout { */ public Boolean checkIfFileIsDuplicate(final String name, final SoftwareModule selectedSoftwareModule) { Boolean isDuplicate = false; - final String currentBaseSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion( - selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); + final String currentBaseSoftwareModuleKey = HawkbitCommonUtil + .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); for (final CustomFile customFile : artifactUploadState.getFileSelected()) { final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion( @@ -510,9 +512,9 @@ public class UploadLayout extends VerticalLayout { artifactUploadState.getNumberOfFileUploadsExpected().incrementAndGet(); } - void updateFileSize(final String name, final long size, SoftwareModule selectedSoftwareModule) { - final String currentBaseSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion( - selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); + void updateFileSize(final String name, final long size, final SoftwareModule selectedSoftwareModule) { + final String currentBaseSoftwareModuleKey = HawkbitCommonUtil + .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); for (final CustomFile customFile : artifactUploadState.getFileSelected()) { final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion( @@ -594,12 +596,12 @@ public class UploadLayout extends VerticalLayout { private void setConfirmationPopupHeightWidth(final float newWidth, final float newHeight) { if (currentUploadConfirmationwindow != null) { - currentUploadConfirmationwindow.getUploadArtifactDetails().setWidth( - HawkbitCommonUtil.getArtifactUploadPopupWidth(newWidth, - SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH), Unit.PIXELS); - currentUploadConfirmationwindow.getUploadDetailsTable().setHeight( - HawkbitCommonUtil.getArtifactUploadPopupHeight(newHeight, - SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT), Unit.PIXELS); + currentUploadConfirmationwindow.getUploadArtifactDetails().setWidth(HawkbitCommonUtil + .getArtifactUploadPopupWidth(newWidth, SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH), + Unit.PIXELS); + currentUploadConfirmationwindow.getUploadDetailsTable().setHeight(HawkbitCommonUtil + .getArtifactUploadPopupHeight(newHeight, SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT), + Unit.PIXELS); } } @@ -616,12 +618,10 @@ public class UploadLayout extends VerticalLayout { && currentUploadConfirmationwindow.getCurrentUploadResultWindow() != null) { final UploadResultWindow uploadResultWindow = currentUploadConfirmationwindow .getCurrentUploadResultWindow(); - uploadResultWindow.getUploadResultsWindow().setWidth( - HawkbitCommonUtil.getArtifactUploadPopupWidth(newWidth, - SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH), Unit.PIXELS); - uploadResultWindow.getUploadResultTable().setHeight( - HawkbitCommonUtil.getArtifactUploadPopupHeight(newHeight, - SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT), Unit.PIXELS); + uploadResultWindow.getUploadResultsWindow().setWidth(HawkbitCommonUtil.getArtifactUploadPopupWidth(newWidth, + SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH), Unit.PIXELS); + uploadResultWindow.getUploadResultTable().setHeight(HawkbitCommonUtil.getArtifactUploadPopupHeight( + newHeight, SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT), Unit.PIXELS); } } @@ -632,8 +632,8 @@ public class UploadLayout extends VerticalLayout { } else { currentUploadConfirmationwindow = new UploadConfirmationwindow(this, artifactUploadState); UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfrimationWindow()); - setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(), Page.getCurrent() - .getBrowserWindowHeight()); + setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(), + Page.getCurrent().getBrowserWindowHeight()); } } } @@ -682,7 +682,7 @@ public class UploadLayout extends VerticalLayout { displayDuplicateValidationMessage(); } - private void onUploadStreamingFailure(UploadStatusEvent event) { + private void onUploadStreamingFailure(final UploadStatusEvent event) { /** * If upload interrupted because of duplicate file,do not remove the * file already in upload list @@ -691,13 +691,13 @@ public class UploadLayout extends VerticalLayout { || !getDuplicateFileNamesList().contains(event.getUploadStatus().getFileName())) { final SoftwareModule sw = event.getUploadStatus().getSoftwareModule(); if (sw != null) { - getFileSelected().remove( - new CustomFile(event.getUploadStatus().getFileName(), sw.getName(), sw.getVersion())); + getFileSelected() + .remove(new CustomFile(event.getUploadStatus().getFileName(), sw.getName(), sw.getVersion())); } // failed reason to be updated only if there is error other than // duplicate file error - uploadInfoWindow.uploadFailed(event.getUploadStatus().getFileName(), event.getUploadStatus() - .getFailureReason(), event.getUploadStatus().getSoftwareModule()); + uploadInfoWindow.uploadFailed(event.getUploadStatus().getFileName(), + event.getUploadStatus().getFailureReason(), event.getUploadStatus().getSoftwareModule()); increaseNumberOfFileUploadsFailed(); } decreaseNumberOfFileUploadsExpected(); @@ -711,9 +711,9 @@ public class UploadLayout extends VerticalLayout { displayDuplicateValidationMessage(); } - private void onUploadSuccess(UploadStatusEvent event) { - updateFileSize(event.getUploadStatus().getFileName(), event.getUploadStatus().getContentLength(), event - .getUploadStatus().getSoftwareModule()); + private void onUploadSuccess(final UploadStatusEvent event) { + updateFileSize(event.getUploadStatus().getFileName(), event.getUploadStatus().getContentLength(), + event.getUploadStatus().getSoftwareModule()); // recorded that we now one more uploaded increaseNumberOfFilesActuallyUpload(); } @@ -730,8 +730,8 @@ public class UploadLayout extends VerticalLayout { } private boolean isUploadComplete() { - int uploadedCount = artifactUploadState.getNumberOfFilesActuallyUpload().intValue(); - int expectedUploadsCount = artifactUploadState.getNumberOfFileUploadsExpected().intValue(); + final int uploadedCount = artifactUploadState.getNumberOfFilesActuallyUpload().intValue(); + final int expectedUploadsCount = artifactUploadState.getNumberOfFileUploadsExpected().intValue(); return uploadedCount == expectedUploadsCount; } @@ -744,13 +744,13 @@ public class UploadLayout extends VerticalLayout { || !getDuplicateFileNamesList().contains(event.getUploadStatus().getFileName())) { final SoftwareModule sw = event.getUploadStatus().getSoftwareModule(); if (sw != null) { - getFileSelected().remove( - new CustomFile(event.getUploadStatus().getFileName(), sw.getName(), sw.getVersion())); + getFileSelected() + .remove(new CustomFile(event.getUploadStatus().getFileName(), sw.getName(), sw.getVersion())); } // failed reason to be updated only if there is error other than // duplicate file error - uploadInfoWindow.uploadFailed(event.getUploadStatus().getFileName(), event.getUploadStatus() - .getFailureReason(), event.getUploadStatus().getSoftwareModule()); + uploadInfoWindow.uploadFailed(event.getUploadStatus().getFileName(), + event.getUploadStatus().getFailureReason(), event.getUploadStatus().getSoftwareModule()); increaseNumberOfFileUploadsFailed(); decreaseNumberOfFileUploadsExpected(); } @@ -773,8 +773,8 @@ public class UploadLayout extends VerticalLayout { * @param selectedBaseSoftwareModule */ public void refreshArtifactDetailsLayout(final SoftwareModule selectedBaseSoftwareModule) { - eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED, - selectedBaseSoftwareModule)); + eventBus.publish(this, + new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED, selectedBaseSoftwareModule)); } /** @@ -804,10 +804,10 @@ public class UploadLayout extends VerticalLayout { } void updateStatusButtonCount() { - int uploadsPending = artifactUploadState.getNumberOfFileUploadsExpected().get() + final int uploadsPending = artifactUploadState.getNumberOfFileUploadsExpected().get() - artifactUploadState.getNumberOfFilesActuallyUpload().get(); - int uploadsFailed = artifactUploadState.getNumberOfFileUploadsFailed().get(); - StringBuilder builder = new StringBuilder(""); + final int uploadsFailed = artifactUploadState.getNumberOfFileUploadsFailed().get(); + final StringBuilder builder = new StringBuilder(""); if (uploadsFailed != 0) { if (uploadsPending != 0) { builder.append("
" + uploadsFailed + "
"); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/colorpicker/ColorPickerConstants.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/colorpicker/ColorPickerConstants.java index 06e280e4e..86a986e3a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/colorpicker/ColorPickerConstants.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/colorpicker/ColorPickerConstants.java @@ -14,7 +14,7 @@ import com.vaadin.shared.ui.colorpicker.Color; * Provides color constants for the ColorPickerLayout * */ -public class ColorPickerConstants { +public final class ColorPickerConstants { public static final String DEFAULT_COLOR = "rgb(44,151,32)"; public static final Color START_COLOR = new Color(0, 146, 58); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/colorpicker/ColorPickerHelper.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/colorpicker/ColorPickerHelper.java index 923c58fe3..1f80bf5ab 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/colorpicker/ColorPickerHelper.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/colorpicker/ColorPickerHelper.java @@ -20,7 +20,7 @@ import com.vaadin.ui.Slider.ValueOutOfBoundsException; * Contains helper methods for the ColorPickerLayout to handle the ColorPicker * */ -public class ColorPickerHelper { +public final class ColorPickerHelper { private static final Logger LOG = LoggerFactory.getLogger(ColorPickerHelper.class); @@ -30,7 +30,9 @@ public class ColorPickerHelper { /** * Get color picked value as string. - * + * + * @param preview + * the color picker preview * @return String of color picked value. */ public static String getColorPickedString(final SpColorPickerPreview preview) { @@ -59,7 +61,7 @@ public class ColorPickerHelper { final int green = Integer.parseInt(colors[1]); final int blue = Integer.parseInt(colors[2]); if (colors.length > 3) { - final int alpha = (int) (Double.parseDouble(colors[3]) * 255d); + final int alpha = (int) (Double.parseDouble(colors[3]) * 255D); return new Color(red, green, blue, alpha); } return new Color(red, green, blue); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/polling/DurationConfigField.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/polling/DurationConfigField.java index 15f51877d..9a3a54a5e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/polling/DurationConfigField.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/polling/DurationConfigField.java @@ -24,7 +24,7 @@ import com.vaadin.ui.GridLayout; * duration in the DurationField or he can configure using the global duration * by changing the CheckBox. */ -public class DurationConfigField extends GridLayout implements ConfigurationItem { +public final class DurationConfigField extends GridLayout implements ConfigurationItem { private static final long serialVersionUID = 1L; @@ -130,45 +130,96 @@ public class DurationConfigField extends GridLayout implements ConfigurationItem configurationChangeListeners.add(listener); } + /** + * Create a DurationConfigFieldBuilder. + * + * @return the builder + */ public static DurationConfigFieldBuilder builder() { return new DurationConfigFieldBuilder(); } - public static class DurationConfigFieldBuilder { + /** + * Builder for the calendar widget. + * + */ + public static final class DurationConfigFieldBuilder { private final DurationConfigField field; - private Duration globalDuration = null; - private Duration tenantDuration = null; + private Duration globalDuration; + private Duration tenantDuration; private DurationConfigFieldBuilder() { field = new DurationConfigField(); - }; + } + /** + * set the checkbox tooltip. + * + * @param label + * the tooltip + * @return the builder + */ public DurationConfigFieldBuilder checkBoxTooltip(final String label) { field.setCheckBoxTooltip(label); return this; } + /** + * set the global duration. + * + * @param globalDuration + * the global duration + * @return the builder + */ public DurationConfigFieldBuilder globalDuration(final Duration globalDuration) { this.globalDuration = globalDuration; return this; } + /** + * set the caption. + * + * @param caption + * the caption + * @return the builder + */ public DurationConfigFieldBuilder caption(final String caption) { field.setCaption(caption); return this; } + /** + * set the range. + * + * @param minDuration + * min duration + * @param maxDuration + * max duration + * @return the builder + */ public DurationConfigFieldBuilder range(final Duration minDuration, final Duration maxDuration) { field.setAllowedRange(minDuration, maxDuration); return this; } + /** + * set the tenant duration. + * + * @param tenantDuration + * the duration + * @return the builder + */ public DurationConfigFieldBuilder tenantDuration(final Duration tenantDuration) { this.tenantDuration = tenantDuration; return this; } + /** + * Create the {@link DurationConfigField}. + * + * @return the {@link DurationConfigField} + */ public DurationConfigField build() { if (globalDuration == null) { throw new IllegalStateException( @@ -178,5 +229,5 @@ public class DurationConfigField extends GridLayout implements ConfigurationItem field.init(globalDuration, tenantDuration); return field; } - }; + } }