package net.onrc.onos.core.matchaction;

import net.onrc.onos.core.util.IdBlock;
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 MatchActionIdId.
 */
public class MatchActionIdGeneratorWithIdBlockAllocator
        implements MatchActionIdGenerator {

        private final IdBlockAllocator allocator;
        private IdBlock idBlock;

        /**
          * Creates a FlowId generator instance using specified ID block allocator.
          *
          * @param allocator the ID block allocator to be used
          */
        public MatchActionIdGeneratorWithIdBlockAllocator(IdBlockAllocator allocator) {
            this.allocator = checkNotNull(allocator);
            this.idBlock = allocator.allocateUniqueIdBlock();
        }

        @Override
        public synchronized MatchActionId getNewId() {
            try {
                return new MatchActionId(idBlock.getNextId());
            } catch (UnavailableIdException e) {
                idBlock = allocator.allocateUniqueIdBlock();
                return new MatchActionId(idBlock.getNextId());
            }
        }
}

@@ -400,20 +400,16 @@
 ator %7B%0A%0A
-    
     priv
@@ -446,20 +446,16 @@
 ocator;%0A
-    
     priv
@@ -484,21 +484,12 @@
     
-   
- 
 /**%0A
-     
     
@@ -572,20 +572,10 @@
     
-    
- 
 *%0A
-     
     
@@ -632,21 +632,16 @@
 sed%0A
-     
      */%0A
     
@@ -636,20 +636,16 @@
      */%0A
-    
     publ
@@ -724,28 +724,24 @@
 ) %7B%0A        
-    
 this.allocat
@@ -774,28 +774,24 @@
 r);%0A        
-  
-  
 this.idBlock
@@ -836,19 +836,11 @@
     
-    %7D%0A%0A    
+%7D%0A%0A
     
@@ -853,20 +853,16 @@
 ide%0A    
- 
-   
 public s
@@ -908,20 +908,16 @@
         
-    
 try %7B%0A  
@@ -918,36 +918,32 @@
 y %7B%0A            
-   
- 
 return new Match
@@ -981,20 +981,16 @@
         
-    
 %7D catch 
@@ -1030,20 +1030,16 @@
         
- 
-   
 idBlock 
@@ -1079,36 +1079,32 @@
 ();%0A            
-  
-  
 return new Match
@@ -1146,18 +1146,10 @@
     
-    %7D%0A    
+%7D%0A
     

Reformat code: fix indent