Merge into master from pull request #140:
OFPortBitMap: add functionality to iterate over the Ports (https://github.com/floodlight/loxigen/pull/140)
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPortBitMap.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPortBitMap.java
index b9c2b75..18ab8b0 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPortBitMap.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFPortBitMap.java
@@ -1,5 +1,7 @@
 package org.projectfloodlight.openflow.types;
 
+import java.util.ArrayList;
+
 import javax.annotation.concurrent.Immutable;
 
 
@@ -61,6 +63,20 @@
         return builder.build();
     }
 
+    public static OFPortBitMap of(OFBitMask128 mask) {
+        return new OFPortBitMap(mask);
+    }
+
+    public Iterable<OFPort> getOnPorts() {
+        ArrayList<OFPort> ports = new ArrayList<>();
+        for(int i=0; i < 127; i++) {
+            if(!(this.mask.isOn(i))) {
+                ports.add(OFPort.of(i));
+            }
+        }
+        return ports;
+    }
+
     @Override
     public boolean equals(Object obj) {
         if (!(obj instanceof OFPortBitMap))
diff --git a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/OFPortBitMapTest.java b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/OFPortBitMapTest.java
index 7f5ab5d..fc214e5 100644
--- a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/OFPortBitMapTest.java
+++ b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/OFPortBitMapTest.java
@@ -1,11 +1,38 @@
 package org.projectfloodlight.openflow.types;
 
+import static org.hamcrest.CoreMatchers.equalTo;
 import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertThat;
 import junit.framework.TestCase;
 
 import org.junit.Test;
 
+import com.google.common.collect.ImmutableList;
+
 public class OFPortBitMapTest extends TestCase {
+    @Test
+    public void testCreateAndIterate() {
+        OFPortBitMap map = OFPortBitMap.ofPorts(OFPort.of(1), OFPort.of(2), OFPort.of(5));
+
+        assertThat(
+                ImmutableList.copyOf(map.getOnPorts()),
+                equalTo(
+                   ImmutableList.of(OFPort.of(1), OFPort.of(2), OFPort.of(5))
+                ));
+    }
+
+    @Test
+    public void testOFBitMap() {
+        OFBitMask128 bitmap = OFBitMask128.of(0xFFFF_FFFF_FFFF_FFFFL, 0xFFFF_FFFF_FFFF_FFD9L);
+
+        OFPortBitMap map = OFPortBitMap.of(bitmap);
+
+        assertThat(
+                ImmutableList.copyOf(map.getOnPorts()),
+                equalTo(
+                   ImmutableList.of(OFPort.of(1), OFPort.of(2), OFPort.of(5))
+                ));
+    }
 
     @Test
     public void testOFPortBitMap() {