+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.server.util;\r
+\r
+import jetbrains.buildServer.serverSide.InvalidProperty;\r
+import jetbrains.buildServer.serverSide.PropertiesProcessor;\r
+import jetbrains.buildServer.util.StringUtil;\r
+import org.jetbrains.annotations.NotNull;\r
+import org.jetbrains.annotations.Nullable;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.Map;\r
+\r
+/**\r
+ * @author Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 23.08.11 10:59\r
+ */\r
+public abstract class BasePropertiesProcessor implements PropertiesProcessor {\r
+ @Nullable\r
+ protected static String notEmpty(@NotNull final String key,\r
+ @NotNull String errorMessage,\r
+ @NotNull final Map<String, String> params,\r
+ @NotNull final Collection<InvalidProperty> result) {\r
+ final String value = params.get(key);\r
+ if (StringUtil.isEmptyOrSpaces(value)) {\r
+ result.add(new InvalidProperty(key, errorMessage));\r
+ return null;\r
+ }\r
+ return value;\r
+ }\r
+\r
+ @NotNull\r
+ public final Collection<InvalidProperty> process(final Map<String, String> properties) {\r
+ Collection<InvalidProperty> result = new ArrayList<InvalidProperty>();\r
+\r
+ if (properties == null) return result;\r
+ checkProperties(Collections.unmodifiableMap(properties), result);\r
+\r
+ return result;\r
+ }\r
+\r
+ protected abstract void checkProperties(@NotNull final Map<String, String> map, @NotNull Collection<InvalidProperty> result);\r
+}\r