Use Strings.isNullOrEmpty() 23/29823/4
authorRobert Varga <robert.varga@pantheon.sk>
Tue, 17 Nov 2015 17:01:37 +0000 (18:01 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 19 Nov 2015 13:07:30 +0000 (13:07 +0000)
Instead of open-coding the check, use the library.

Change-Id: Idbb42a140e3a52fa3d3b131bd1d674270bd02abd
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java

index 85ea46b1f1e18d8dd6cf45bdab4fc4d87adee373..ea52e1ef32539610139d090e0f862b77083b756a 100644 (file)
@@ -11,6 +11,7 @@ import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findD
 import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNodeForRelativeXPath;
 import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule;
 import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
 import com.google.common.collect.Sets;
 import com.google.common.io.BaseEncoding;
 import java.io.Serializable;
@@ -1356,6 +1357,7 @@ public final class TypeProviderImpl implements TypeProvider {
      *         definition to the base type
      */
     private static int getTypeDefinitionDepth(final TypeDefinition<?> typeDefinition) {
+        // FIXME: rewrite this in a non-recursive manner, without ExtendedType and UnionType
         if (typeDefinition == null) {
             return 1;
         }
@@ -1399,7 +1401,7 @@ public final class TypeProviderImpl implements TypeProvider {
     }
 
     public static void addUnitsToGenTO(final GeneratedTOBuilder to, final String units) {
-        if (units != null && !units.isEmpty()) {
+        if (!Strings.isNullOrEmpty(units)) {
             to.addConstant(Types.STRING, "_UNITS", "\"" + units + "\"");
             GeneratedPropertyBuilder prop = new GeneratedPropertyBuilderImpl("UNITS");
             prop.setReturnType(Types.STRING);