Migrate String padding 78/79178/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 3 Jan 2019 14:06:09 +0000 (15:06 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 3 Jan 2019 14:06:09 +0000 (15:06 +0100)
Guava provides a more efficient equivalent of StringUtils.padLeft(),
migrate to it, reducing dependencies on commons-lang3 a bit.

Change-Id: Ia5c17ed3dad39d7f1d2c397299da133a54a3c7c5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPUtil.java
openflowplugin/pom.xml
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/InventoryDataServiceUtil.java

index 869e92618c531589603f4a504781403369a6fd55..28b4268c1e16e5f087eb813c4bfe447a048c2777 100644 (file)
@@ -5,15 +5,14 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.openflowplugin.applications.lldpspeaker;
 
 import static org.opendaylight.openflowplugin.applications.topology.lldp.utils.LLDPDiscoveryUtils.getValueForLLDPPacketIntegrityEnsuring;
 
+import com.google.common.base.Strings;
 import java.math.BigInteger;
 import java.security.NoSuchAlgorithmException;
 import javax.annotation.Nonnull;
-import org.apache.commons.lang3.StringUtils;
 import org.opendaylight.openflowplugin.libraries.liblldp.EtherTypes;
 import org.opendaylight.openflowplugin.libraries.liblldp.Ethernet;
 import org.opendaylight.openflowplugin.libraries.liblldp.HexEncode;
@@ -119,6 +118,6 @@ public final class LLDPUtil {
     }
 
     private static String bigIntegerToPaddedHex(final BigInteger dataPathId) {
-        return StringUtils.leftPad(dataPathId.toString(16), 16, "0");
+        return Strings.padStart(dataPathId.toString(16), 16, '0');
     }
 }
index 8f78142c2def5e2b1cc9bbeb6d4c804e6f0156f5..4c2b9e860b17900432b3d37c830693ec9837daef 100644 (file)
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-        </dependency>
 
         <dependency>
             <groupId>junit</groupId>
index 4b834db095ef83e54c2d6f3c5f1607f8a7ee5dd7..6bd8eae90bca17d7dcdec401e4caba1c180a24a3 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -8,11 +8,11 @@
 package org.opendaylight.openflowplugin.openflow.md.util;
 
 import com.google.common.base.Splitter;
+import com.google.common.base.Strings;
 import java.math.BigInteger;
 import java.util.List;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-import org.apache.commons.lang3.StringUtils;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
@@ -157,7 +157,7 @@ public abstract class InventoryDataServiceUtil {
      * @return string of size 16, padded with '0'
      */
     public static String bigIntegerToPaddedHex(final BigInteger dataPathId) {
-        return StringUtils.leftPad(dataPathId.toString(16), 16, "0");
+        return Strings.padStart(dataPathId.toString(16), 16, '0');
     }
 
     public static BigInteger extractDatapathId(final NodeRef ref) {