/*
 * Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
 * Haulmont Technology proprietary and confidential.
 * Use is subject to license terms.

 * Author: Konstantin Krivopustov
 * Created: 24.12.2008 15:14:08
 *
 * $Id$
 */
package com.haulmont.cuba.security.entity;

import com.haulmont.chile.core.datatypes.impl.EnumClass;

/**
 * Type of permission<br>
 * id - corresponding database value
 */
public enum PermissionType implements EnumClass
{
    SCREEN(10),
    ENTITY_OP(20),
    ENTITY_ATTR(30),
    SPECIFIC(40);

    private int id;

    PermissionType(int id) {
        this.id = id;
    }

    /** Returns corresponding database value */
    public int getValue() {
        return id;
    }

    /** Constructs type from corresponding database value */
    public static PermissionType valueOf(int id) {
        for (PermissionType type : PermissionType.values()) {
            if (type.getValue() == id) {
                return type;
            }
        }
        return null;
    }
}

@@ -348,16 +348,61 @@
 mClass;%0D
+%0Aimport org.apache.commons.lang.ObjectUtils;%0D
 %0A%0D%0A/**%0D%0A
@@ -518,16 +518,25 @@
 numClass
+%3CInteger%3E
 %0D%0A%7B%0D%0A   
@@ -757,19 +757,23 @@
  public 
-i
+I
 nt
+eger
  getValu
@@ -911,19 +911,23 @@
 valueOf(
-i
+I
 nt
+eger
  id) %7B%0D%0A
@@ -1004,16 +1004,35 @@
      if 
+(ObjectUtils.equals
 (type.ge
@@ -1043,15 +1043,14 @@
 ue()
- ==
+,
  id)
+)
  %7B%0D%0A

refactor EnumClass