Extract common ID generation logic using IdBlockAllocator

- Define IdGenerator<T> interface
- Implement AbstractIdBlockAllocatorBasedIdGenerator<T>, which
  has the common logic for the existing IntentId, FlowId, MatchActionId,
  and MatchActionOperationsId generator implementations.

Change-Id: I7aeea249df1710719760ed477bffe62853577e0f
diff --git a/src/main/java/net/onrc/onos/core/matchaction/MatchActionIdGeneratorWithIdBlockAllocator.java b/src/main/java/net/onrc/onos/core/matchaction/MatchActionIdGeneratorWithIdBlockAllocator.java
index 14a09c2..ef255d0 100644
--- a/src/main/java/net/onrc/onos/core/matchaction/MatchActionIdGeneratorWithIdBlockAllocator.java
+++ b/src/main/java/net/onrc/onos/core/matchaction/MatchActionIdGeneratorWithIdBlockAllocator.java
@@ -1,19 +1,13 @@
 package net.onrc.onos.core.matchaction;
 
-import net.onrc.onos.core.util.IdBlock;
+import net.onrc.onos.core.util.AbstractBlockAllocatorBasedIdGenerator;
 import net.onrc.onos.core.util.IdBlockAllocator;
-import net.onrc.onos.core.util.UnavailableIdException;
-
-import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
  * Generates a global unique MatchActionId.
  */
 public class MatchActionIdGeneratorWithIdBlockAllocator
-        implements MatchActionIdGenerator {
-
-    private final IdBlockAllocator allocator;
-    private IdBlock idBlock;
+        extends AbstractBlockAllocatorBasedIdGenerator<MatchActionId> {
 
     /**
      * Creates a FlowId generator instance using specified ID block allocator.
@@ -21,17 +15,11 @@
      * @param allocator the ID block allocator to be used
      */
     public MatchActionIdGeneratorWithIdBlockAllocator(IdBlockAllocator allocator) {
-        this.allocator = checkNotNull(allocator);
-        this.idBlock = allocator.allocateUniqueIdBlock();
+        super(allocator);
     }
 
     @Override
-    public synchronized MatchActionId getNewId() {
-        try {
-            return new MatchActionId(idBlock.getNextId());
-        } catch (UnavailableIdException e) {
-            idBlock = allocator.allocateUniqueIdBlock();
-            return new MatchActionId(idBlock.getNextId());
-        }
+    protected MatchActionId convertFrom(long value) {
+        return new MatchActionId(value);
     }
 }