NIFIREG-7 Removing StringUtils in favor of commons-lang StringUtils. This closes #5
Project: http://git-wip-us.apache.org/repos/asf/nifi-registry/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi-registry/commit/7dd88eb4 Tree: http://git-wip-us.apache.org/repos/asf/nifi-registry/tree/7dd88eb4 Diff: http://git-wip-us.apache.org/repos/asf/nifi-registry/diff/7dd88eb4 Branch: refs/heads/master Commit: 7dd88eb441e1dd84f3ce0839e2bf25ff475a9e00 Parents: 9eb0cef Author: Bryan Bende <[email protected]> Authored: Tue Aug 22 14:34:43 2017 -0400 Committer: Matt Gilman <[email protected]> Committed: Tue Aug 22 15:50:37 2017 -0400 ---------------------------------------------------------------------- nifi-registry-provider-impl/pom.xml | 4 + .../flow/FileSystemFlowPersistenceProvider.java | 2 +- .../metadata/FileSystemMetadataProvider.java | 2 +- .../apache/nifi/registry/util/StringUtils.java | 99 -------------------- 4 files changed, 6 insertions(+), 101 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7dd88eb4/nifi-registry-provider-impl/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-provider-impl/pom.xml b/nifi-registry-provider-impl/pom.xml index f5999af..2405ba9 100644 --- a/nifi-registry-provider-impl/pom.xml +++ b/nifi-registry-provider-impl/pom.xml @@ -75,6 +75,10 @@ <artifactId>commons-io</artifactId> </dependency> <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7dd88eb4/nifi-registry-provider-impl/src/main/java/org/apache/nifi/registry/flow/FileSystemFlowPersistenceProvider.java ---------------------------------------------------------------------- diff --git a/nifi-registry-provider-impl/src/main/java/org/apache/nifi/registry/flow/FileSystemFlowPersistenceProvider.java b/nifi-registry-provider-impl/src/main/java/org/apache/nifi/registry/flow/FileSystemFlowPersistenceProvider.java index fc14c14..db09a6d 100644 --- a/nifi-registry-provider-impl/src/main/java/org/apache/nifi/registry/flow/FileSystemFlowPersistenceProvider.java +++ b/nifi-registry-provider-impl/src/main/java/org/apache/nifi/registry/flow/FileSystemFlowPersistenceProvider.java @@ -17,10 +17,10 @@ package org.apache.nifi.registry.flow; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.nifi.registry.provider.ProviderConfigurationContext; import org.apache.nifi.registry.provider.ProviderCreationException; import org.apache.nifi.registry.util.FileUtils; -import org.apache.nifi.registry.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7dd88eb4/nifi-registry-provider-impl/src/main/java/org/apache/nifi/registry/metadata/FileSystemMetadataProvider.java ---------------------------------------------------------------------- diff --git a/nifi-registry-provider-impl/src/main/java/org/apache/nifi/registry/metadata/FileSystemMetadataProvider.java b/nifi-registry-provider-impl/src/main/java/org/apache/nifi/registry/metadata/FileSystemMetadataProvider.java index ccdc1a8..ba3af4c 100644 --- a/nifi-registry-provider-impl/src/main/java/org/apache/nifi/registry/metadata/FileSystemMetadataProvider.java +++ b/nifi-registry-provider-impl/src/main/java/org/apache/nifi/registry/metadata/FileSystemMetadataProvider.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.registry.metadata; +import org.apache.commons.lang3.StringUtils; import org.apache.nifi.registry.bucket.Bucket; import org.apache.nifi.registry.flow.VersionedFlow; import org.apache.nifi.registry.flow.VersionedFlowSnapshot; @@ -25,7 +26,6 @@ import org.apache.nifi.registry.metadata.generated.Flows; import org.apache.nifi.registry.metadata.generated.Metadata; import org.apache.nifi.registry.provider.ProviderConfigurationContext; import org.apache.nifi.registry.provider.ProviderCreationException; -import org.apache.nifi.registry.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xml.sax.SAXException; http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/7dd88eb4/nifi-registry-utils/src/main/java/org/apache/nifi/registry/util/StringUtils.java ---------------------------------------------------------------------- diff --git a/nifi-registry-utils/src/main/java/org/apache/nifi/registry/util/StringUtils.java b/nifi-registry-utils/src/main/java/org/apache/nifi/registry/util/StringUtils.java deleted file mode 100644 index 43ab825..0000000 --- a/nifi-registry-utils/src/main/java/org/apache/nifi/registry/util/StringUtils.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.registry.util; - -import java.util.Collection; - -public class StringUtils { - - public static final String EMPTY = ""; - - public static boolean isBlank(final String str) { - if (str == null || str.isEmpty()) { - return true; - } - for (int i = 0; i < str.length(); i++) { - if (!Character.isWhitespace(str.charAt(i))) { - return false; - } - } - return true; - } - - public static boolean isEmpty(final String str) { - return str == null || str.isEmpty(); - } - - public static boolean startsWith(final String str, final String prefix) { - if (str == null || prefix == null) { - return (str == null && prefix == null); - } - if (prefix.length() > str.length()) { - return false; - } - return str.regionMatches(false, 0, prefix, 0, prefix.length()); - } - - public static String substringAfter(final String str, final String separator) { - if (isEmpty(str)) { - return str; - } - if (separator == null) { - return EMPTY; - } - int pos = str.indexOf(separator); - if (pos == -1) { - return EMPTY; - } - return str.substring(pos + separator.length()); - } - - public static String join(final Collection collection, String delimiter) { - if (collection == null || collection.size() == 0) { - return EMPTY; - } - final StringBuilder sb = new StringBuilder(collection.size() * 16); - for (Object element : collection) { - sb.append((String) element); - sb.append(delimiter); - } - return sb.toString().substring(0, sb.lastIndexOf(delimiter)); - } - - public static String padLeft(final String source, int length, char padding) { - if (source != null) { - StringBuilder sb = new StringBuilder(source).reverse(); - while (sb.length() < length) { - sb.append(padding); - } - return sb.reverse().toString(); - } - return null; - } - - public static String padRight(final String source, int length, char padding) { - if (source != null) { - StringBuilder sb = new StringBuilder(source); - while (sb.length() < length) { - sb.append(padding); - } - return sb.toString(); - } - return null; - } - -}
