diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-07-04 17:36:56 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-07-17 10:52:47 +0200 |
commit | 28886acf8527efacf4f6c9732852aa10b8576459 (patch) | |
tree | 99cc5c89d207b0db9044e08d4217edd278876a51 /server/sonar-server | |
parent | c818fc85b3d32c358b5149647d384cc42f4ba5a1 (diff) | |
download | sonarqube-28886acf8527efacf4f6c9732852aa10b8576459.tar.gz sonarqube-28886acf8527efacf4f6c9732852aa10b8576459.zip |
SONAR-9507 make sonar.ce.workerCount an internal property
Diffstat (limited to 'server/sonar-server')
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/property/MapInternalProperties.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/property/MapInternalProperties.java b/server/sonar-server/src/main/java/org/sonar/server/property/MapInternalProperties.java new file mode 100644 index 00000000000..6f5259325b2 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/property/MapInternalProperties.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.property; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkArgument; + +/** + * Map based implementation of {@link InternalProperties} to be used for unit testing. + */ +public class MapInternalProperties implements InternalProperties { + private final Map<String, String> values = new HashMap<>(1); + + @Override + public Optional<String> read(String propertyKey) { + checkPropertyKey(propertyKey); + return Optional.ofNullable(values.get(propertyKey)); + } + + @Override + public void write(String propertyKey, @Nullable String value) { + checkPropertyKey(propertyKey); + values.put(propertyKey, value); + } + + private static void checkPropertyKey(@Nullable String propertyKey) { + checkArgument(propertyKey != null && !propertyKey.isEmpty(), "property key can't be null nor empty"); + } +} |