mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	Implement equals() and hashCode() for permissions.
This commit is contained in:
		| @@ -66,4 +66,26 @@ public class GuacamoleConfigurationDirectoryPermission | ||||
|         return type; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int hashCode() { | ||||
|         return type.hashCode(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean equals(Object obj) { | ||||
|  | ||||
|         // Not equal if null or wrong type | ||||
|         if (obj == null) return false; | ||||
|         if (getClass() != obj.getClass()) return false; | ||||
|  | ||||
|         final GuacamoleConfigurationDirectoryPermission other = | ||||
|                 (GuacamoleConfigurationDirectoryPermission) obj; | ||||
|  | ||||
|         // Compare types | ||||
|         if (type != other.type) | ||||
|             return false; | ||||
|  | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -86,4 +86,36 @@ public class GuacamoleConfigurationPermission | ||||
|         return type; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int hashCode() { | ||||
|         int hash = 5; | ||||
|         if (identifier != null) hash = 47 * hash + identifier.hashCode(); | ||||
|         if (type != null)       hash = 47 * hash + type.hashCode(); | ||||
|         return hash; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean equals(Object obj) { | ||||
|  | ||||
|         // Not equal if null or wrong type | ||||
|         if (obj == null) return false; | ||||
|         if (getClass() != obj.getClass()) return false; | ||||
|  | ||||
|         final GuacamoleConfigurationPermission other = | ||||
|                 (GuacamoleConfigurationPermission) obj; | ||||
|  | ||||
|         // Not equal if different type | ||||
|         if (this.type != other.type) | ||||
|             return false; | ||||
|  | ||||
|         // If null identifier, equality depends on whether other identifier | ||||
|         // is null | ||||
|         if (identifier == null) | ||||
|             return other.identifier != null; | ||||
|  | ||||
|         // Otherwise, equality depends entirely on identifier | ||||
|         return identifier.equals(other.identifier); | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -64,4 +64,25 @@ public class UserDirectoryPermission implements SystemPermission { | ||||
|         return type; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int hashCode() { | ||||
|         return type.hashCode(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean equals(Object obj) { | ||||
|  | ||||
|         // Not equal if null or wrong type | ||||
|         if (obj == null) return false; | ||||
|         if (getClass() != obj.getClass()) return false; | ||||
|  | ||||
|         final UserDirectoryPermission other = (UserDirectoryPermission) obj; | ||||
|  | ||||
|         // Compare types | ||||
|         if (type != other.type) | ||||
|             return false; | ||||
|  | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -82,4 +82,35 @@ public class UserPermission implements ObjectPermission<String> { | ||||
|         return type; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int hashCode() { | ||||
|         int hash = 5; | ||||
|         if (identifier != null) hash = 47 * hash + identifier.hashCode(); | ||||
|         if (type != null)       hash = 47 * hash + type.hashCode(); | ||||
|         return hash; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean equals(Object obj) { | ||||
|  | ||||
|         // Not equal if null or wrong type | ||||
|         if (obj == null) return false; | ||||
|         if (getClass() != obj.getClass()) return false; | ||||
|  | ||||
|         final UserPermission other = (UserPermission) obj; | ||||
|  | ||||
|         // Not equal if different type | ||||
|         if (this.type != other.type) | ||||
|             return false; | ||||
|  | ||||
|         // If null identifier, equality depends on whether other identifier | ||||
|         // is null | ||||
|         if (identifier == null) | ||||
|             return other.identifier != null; | ||||
|  | ||||
|         // Otherwise, equality depends entirely on identifier | ||||
|         return identifier.equals(other.identifier); | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user