1 package org.apache.archiva.redback.rbac.memory;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.redback.rbac.Operation;
23 import org.apache.archiva.redback.rbac.Resource;
24 import org.apache.archiva.redback.rbac.Permission;
29 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
32 public class MemoryPermission
33 implements Permission, java.io.Serializable
44 private String description;
49 private MemoryOperation operation;
54 private MemoryResource resource;
59 private boolean permanent = false;
66 public boolean equals( Object other )
73 if ( !( other instanceof MemoryPermission ) )
78 MemoryPermission that = (MemoryPermission) other;
79 boolean result = true;
80 result = result && ( getName() == null ? that.getName() == null : getName().equals( that.getName() ) );
87 public String getDescription()
89 return this.description;
95 public String getName()
103 public Operation getOperation()
105 return (Operation) this.operation;
111 public Resource getResource()
113 return (Resource) this.resource;
119 public int hashCode()
122 result = 37 * result + ( name != null ? name.hashCode() : 0 );
131 public void setDescription( String description )
133 this.description = description;
141 public void setName( String name )
151 public void setOperation( Operation operation )
153 if ( !( operation instanceof Operation ) )
155 throw new ClassCastException( "MemoryPermission.setOperation(operation) parameter must be instanceof "
156 + Operation.class.getName() );
158 this.operation = (MemoryOperation) operation;
166 public void setResource( Resource resource )
168 if ( !( resource instanceof Resource ) )
170 throw new ClassCastException( "MemoryPermission.setResource(resource) parameter must be instanceof "
171 + Resource.class.getName() );
173 this.resource = (MemoryResource) resource;
179 public String toString()
181 StringBuffer buf = new StringBuffer();
182 buf.append( "name = '" );
183 buf.append( getName() + "'" );
184 return buf.toString();
187 public boolean isPermanent()
192 public void setPermanent( boolean permanent )
194 this.permanent = permanent;