package com.kryptnostic.mapstores.v2;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.EnumSet;
import java.util.Set;

public enum Permission {
    READ, WRITE, OWNER;

    public static void serializeSet( DataOutput out, Set<Permission> set ) throws IOException {
        for ( Permission permission : Permission.values() ) {
            out.writeBoolean( set.contains( permission ) );
        }
    }

    public static Set<Permission> deserializeSet( DataInput in) throws IOException {
        EnumSet<Permission> permissions = EnumSet.noneOf( Permission.class );
        if ( in.readBoolean() ) {
            permissions.add( READ );
        }
        if ( in.readBoolean() ) {
            permissions.add( WRITE );
        }
        if ( in.readBoolean() ) {
            permissions.add( OWNER );
        }
        return permissions;
    }
}

@@ -622,81 +622,66 @@
     
-if ( in.readBoolean() ) %7B%0A            permissions.add( READ );%0A        %7D%0A
+for ( Permission permission : Permission.values() ) %7B%0A    
     
@@ -714,32 +714,36 @@
 ) %7B%0A            
+    
 permissions.add(
@@ -747,98 +747,35 @@
 dd( 
-WRITE );%0A        %7D%0A        if ( in.readBoolean() ) %7B%0A            permissions.add( OWNER );
+permission );%0A            %7D
 %0A   

use cleaner code for enum set serialization