ovsdb enable checkstyle on error
[ovsdb.git] / southbound / southbound-impl / src / main / java / org / opendaylight / ovsdb / southbound / ovsdb / transact / TransactUtils.java
index 3accf490c5fcf8b38ea97d749a19112fee78ef5e..09e90faee1a6dc785dc50493552177071eac9aeb 100644 (file)
@@ -9,6 +9,12 @@ package org.opendaylight.ovsdb.southbound.ovsdb.transact;
 
 import static org.opendaylight.ovsdb.lib.operations.Operations.op;
 
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -19,10 +25,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Queue;
 import java.util.Set;
-
 import javax.annotation.Nullable;
-
-import com.google.common.base.Predicate;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
@@ -41,25 +44,14 @@ import org.opendaylight.ovsdb.southbound.SouthboundConstants;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 import org.opendaylight.ovsdb.southbound.SouthboundUtil;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-
 import org.opendaylight.yangtools.yang.binding.ChildOf;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.Identifiable;
 import org.opendaylight.yangtools.yang.binding.Identifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
 
 public class TransactUtils {
-    private static final Logger LOG = LoggerFactory.getLogger(TransactUtils.class);
-
     private static <T extends DataObject> Predicate<DataObjectModification<T>> hasDataBefore() {
         return new Predicate<DataObjectModification<T>>() {
             @Override
@@ -116,8 +108,8 @@ public class TransactUtils {
         };
     }
 
-    private static <T extends DataObject> Predicate<DataObjectModification<T>> modificationIsDeletionAndHasDataBefore
-            () {
+    private static <T extends DataObject> Predicate<DataObjectModification<T>>
+        modificationIsDeletionAndHasDataBefore() {
         return new Predicate<DataObjectModification<T>>() {
             @Override
             public boolean apply(@Nullable DataObjectModification<T> input) {
@@ -166,6 +158,25 @@ public class TransactUtils {
         return extractCreatedOrUpdated(changes, clazz, hasNoDataBefore());
     }
 
+    public static <T extends DataObject> Map<InstanceIdentifier<T>,T> extractUpdated(
+            AsyncDataChangeEvent<InstanceIdentifier<?>,DataObject> changes,Class<T> klazz) {
+        return extract(changes.getUpdatedData(),klazz);
+    }
+
+    /**
+     * Extract all the instances of {@code clazz} which were updated in the given set of modifications.
+     *
+     * @param changes The changes to process.
+     * @param clazz The class we're interested in.
+     * @param <T> The type of changes we're interested in.
+     * @param <U> The type of changes to process.
+     * @return The updated instances, mapped by instance identifier.
+     */
+    public static <T extends DataObject, U extends DataObject> Map<InstanceIdentifier<T>, T> extractUpdated(
+            Collection<DataTreeModification<U>> changes, Class<T> clazz) {
+        return extractCreatedOrUpdated(changes, clazz, hasDataBeforeAndDataAfter());
+    }
+
     /**
      * Extract all the instance of {@code clazz} which were created or updated in the given set of modifications, and
      * which satisfy the given filter.
@@ -188,25 +199,6 @@ public class TransactUtils {
         return result;
     }
 
-    public static <T extends DataObject> Map<InstanceIdentifier<T>,T> extractUpdated(
-            AsyncDataChangeEvent<InstanceIdentifier<?>,DataObject> changes,Class<T> klazz) {
-        return extract(changes.getUpdatedData(),klazz);
-    }
-
-    /**
-     * Extract all the instances of {@code clazz} which were updated in the given set of modifications.
-     *
-     * @param changes The changes to process.
-     * @param clazz The class we're interested in.
-     * @param <T> The type of changes we're interested in.
-     * @param <U> The type of changes to process.
-     * @return The updated instances, mapped by instance identifier.
-     */
-    public static <T extends DataObject, U extends DataObject> Map<InstanceIdentifier<T>, T> extractUpdated(
-            Collection<DataTreeModification<U>> changes, Class<T> clazz) {
-        return extractCreatedOrUpdated(changes, clazz, hasDataBeforeAndDataAfter());
-    }
-
     public static <T extends DataObject> Map<InstanceIdentifier<T>,T> extractCreatedOrUpdated(
             AsyncDataChangeEvent<InstanceIdentifier<?>,DataObject> changes,Class<T> klazz) {
         Map<InstanceIdentifier<T>,T> result = extractUpdated(changes,klazz);
@@ -248,7 +240,7 @@ public class TransactUtils {
      * @return The created, updated or removed instances, mapped by instance identifier.
      */
     public static <T extends DataObject, U extends DataObject> Map<InstanceIdentifier<T>, T>
-    extractCreatedOrUpdatedOrRemoved(
+        extractCreatedOrUpdatedOrRemoved(
             Collection<DataTreeModification<U>> changes, Class<T> clazz) {
         Map<InstanceIdentifier<T>, T> result = extractCreatedOrUpdated(changes, clazz);
         result.putAll(extractRemovedObjects(changes, clazz));
@@ -320,9 +312,8 @@ public class TransactUtils {
      * @return The modifications, mapped by instance identifier.
      */
     private static <T extends DataObject, U extends DataObject> Map<InstanceIdentifier<T>, DataObjectModification<T>>
-    extractDataObjectModifications(
-            Collection<DataTreeModification<U>> changes, Class<T> clazz,
-            Predicate<DataObjectModification<T>> filter) {
+        extractDataObjectModifications(Collection<DataTreeModification<U>> changes, Class<T> clazz,
+                                       Predicate<DataObjectModification<T>> filter) {
         List<DataObjectModification<? extends DataObject>> dataObjectModifications = new ArrayList<>();
         List<InstanceIdentifier<? extends DataObject>> paths = new ArrayList<>();
         if (changes != null) {
@@ -346,7 +337,7 @@ public class TransactUtils {
      * @return The modifications, mapped by instance identifier.
      */
     private static <T extends DataObject> Map<InstanceIdentifier<T>, DataObjectModification<T>>
-    extractDataObjectModifications(
+        extractDataObjectModifications(
             Collection<DataObjectModification<? extends DataObject>> changes,
             Collection<InstanceIdentifier<? extends DataObject>> paths, Class<T> clazz,
             Predicate<DataObjectModification<T>> filter) {
@@ -378,20 +369,16 @@ public class TransactUtils {
      * @return The extended path.
      */
     private static <N extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<N>, T extends DataObject>
-    InstanceIdentifier<? extends DataObject> extendPath(
+        InstanceIdentifier<? extends DataObject> extendPath(
             InstanceIdentifier path,
             DataObjectModification child) {
         Class<N> item = (Class<N>) child.getDataType();
         if (child.getIdentifier() instanceof InstanceIdentifier.IdentifiableItem) {
             K key = (K) ((InstanceIdentifier.IdentifiableItem) child.getIdentifier()).getKey();
             KeyedInstanceIdentifier<N, K> extendedPath = path.child(item, key);
-            LOG.debug("Building a new child iid for {} with {} and key {}, resulting in {}",
-                    path, item, extendedPath);
             return extendedPath;
         } else {
             InstanceIdentifier<N> extendedPath = path.child(item);
-            LOG.debug("Building a new child iid for {} with {}, resulting in {}",
-                    path, item, extendedPath);
             return extendedPath;
         }
     }
@@ -463,7 +450,7 @@ public class TransactUtils {
      */
     public static UUID extractNamedUuid(Insert insert) {
         String uuidString = insert.getUuidName() != null
-                ? insert.getUuidName() : SouthboundMapper.getRandomUUID();
+                ? insert.getUuidName() : SouthboundMapper.getRandomUuid();
         insert.setUuidName(uuidString);
         return new UUID(uuidString);
     }
@@ -496,7 +483,7 @@ public class TransactUtils {
     /**
      * This method builds a string by concatenating the 2 character
      * hexadecimal representation of each byte from the input byte array.
-     *
+     * <p>
      * For example: an input byte array containing:
      *   bytes[0] = 'a'
      *   bytes[1] = 'b'
@@ -506,7 +493,7 @@ public class TransactUtils {
      *   bytes[5] = '2'
      *   bytes[6] = '3'
      * returns the string "6162632d313233"
-     *
+     * </p>
      * @param bytes
      *            The byte array to convert to string
      * @return The hexadecimal representation of the byte array. If bytes is