package org.zalando.nakadi.domain;

import org.zalando.nakadi.plugin.api.authz.AuthorizationAttribute;
import org.zalando.nakadi.plugin.api.authz.AuthorizationService;

import javax.annotation.concurrent.Immutable;
import java.util.Objects;

@Immutable
public class Permission {
    private final String resource;
    private final AuthorizationService.Operation operation;
    private final AuthorizationAttribute authorizationAttribute;

    public Permission(final String resource, final AuthorizationService.Operation operation,
                      final AuthorizationAttribute authorizationAttribute) {
        this.resource = resource;
        this.operation = operation;
        this.authorizationAttribute = authorizationAttribute;
    }

    public String getResource() {
        return resource;
    }

    public AuthorizationService.Operation getOperation() {
        return operation;
    }

    public AuthorizationAttribute getAuthorizationAttribute() {
        return authorizationAttribute;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        final Permission that = (Permission) o;
        return Objects.equals(resource, that.resource) &&
                Objects.equals(operation, that.operation) &&
                Objects.equals(authorizationAttribute.getDataType(), that.authorizationAttribute.getDataType()) &&
                Objects.equals(authorizationAttribute.getValue(), that.authorizationAttribute.getValue());
    }

    @Override
    public int hashCode() {
        return Objects.hash(resource, operation, authorizationAttribute);
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("Permission {");
        sb.append("resource: ");
        sb.append(resource);
        sb.append("\tOperation: ");
        sb.append(operation.toString());
        sb.append("\tAuthorization attribute: ");
        sb.append(authorizationAttribute.toString());
        sb.append("}.");
        return sb.toString();
    }
}

@@ -1838,32 +1838,39 @@
 lder();%0A        
+return 
 sb.append(%22Permi
@@ -1880,31 +1880,8 @@
 on %7B
-%22);%0A        sb.append(%22
 reso
@@ -1884,34 +1884,34 @@
 resource: %22)
-;
 %0A
+ 
         
 sb.append(re
@@ -1890,34 +1890,39 @@
 ce: %22)%0A         
-sb
+       
 .append(resource
@@ -1922,17 +1922,16 @@
 esource)
-;
 %0A       
@@ -1923,34 +1923,40 @@
 source)%0A        
-sb
+        
 .append(%22%5CtOpera
@@ -1959,25 +1959,24 @@
 peration: %22)
-;
 %0A        sb.
@@ -1964,34 +1964,40 @@
 ion: %22)%0A        
-sb
+        
 .append(operatio
@@ -2001,33 +2001,32 @@
 tion.toString())
-;
 %0A        sb.appe
@@ -2010,34 +2010,40 @@
 ring())%0A        
-sb
+        
 .append(%22%5CtAutho
@@ -2064,17 +2064,16 @@
 bute: %22)
-;
 %0A       
@@ -2065,34 +2065,40 @@
 ute: %22)%0A        
-sb
+        
 .append(authoriz
@@ -2123,26 +2123,31 @@
 tring())
-;
 %0A
+      
         
 sb.appen
@@ -2138,18 +2138,18 @@
         
-sb
+  
 .append(
@@ -2153,17 +2153,16 @@
 nd(%22%7D.%22)
-;
 %0A       
@@ -2162,25 +2162,24 @@
         
-return sb
+        
 .toStrin

Refactor Permission.toString()