001 /* 002 * JBoss DNA (http://www.jboss.org/dna) 003 * See the COPYRIGHT.txt file distributed with this work for information 004 * regarding copyright ownership. Some portions may be licensed 005 * to Red Hat, Inc. under one or more contributor license agreements. 006 * See the AUTHORS.txt file in the distribution for a full listing of 007 * individual contributors. 008 * 009 * Unless otherwise indicated, all code in JBoss DNA is licensed 010 * to you under the terms of the GNU Lesser General Public License as 011 * published by the Free Software Foundation; either version 2.1 of 012 * the License, or (at your option) any later version. 013 * 014 * JBoss DNA is distributed in the hope that it will be useful, 015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 017 * Lesser General Public License for more details. 018 * 019 * You should have received a copy of the GNU Lesser General Public 020 * License along with this software; if not, write to the Free 021 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 022 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 023 */ 024 package org.jboss.dna.graph.request; 025 026 import org.jboss.dna.common.util.CheckArg; 027 028 /** 029 * Request that an existing workspace with the supplied name be destroyed. 030 */ 031 public final class DestroyWorkspaceRequest extends Request { 032 033 private static final long serialVersionUID = 1L; 034 035 private final String workspaceName; 036 037 /** 038 * Create a request to destroy an existing workspace. 039 * 040 * @param workspaceName the name of the workspace that is to be destroyed 041 * @throws IllegalArgumentException if the workspace name is null 042 */ 043 public DestroyWorkspaceRequest( String workspaceName ) { 044 CheckArg.isNotNull(workspaceName, "workspaceName"); 045 this.workspaceName = workspaceName; 046 } 047 048 /** 049 * Get the name for the workspace that is to be destroyed. 050 * 051 * @return the name for the workspace; never null 052 */ 053 public String workspaceName() { 054 return workspaceName; 055 } 056 057 /** 058 * {@inheritDoc} 059 * 060 * @see org.jboss.dna.graph.request.Request#isReadOnly() 061 */ 062 @Override 063 public boolean isReadOnly() { 064 return false; 065 } 066 067 /** 068 * {@inheritDoc} 069 * 070 * @see java.lang.Object#hashCode() 071 */ 072 @Override 073 public int hashCode() { 074 return workspaceName.hashCode(); 075 } 076 077 /** 078 * {@inheritDoc} 079 * 080 * @see java.lang.Object#equals(java.lang.Object) 081 */ 082 @Override 083 public boolean equals( Object obj ) { 084 if (obj == this) return true; 085 if (this.getClass().isInstance(obj)) { 086 DestroyWorkspaceRequest that = (DestroyWorkspaceRequest)obj; 087 if (!this.workspaceName.equals(that.workspaceName())) return false; 088 return true; 089 } 090 return false; 091 } 092 093 /** 094 * {@inheritDoc} 095 * 096 * @see java.lang.Object#toString() 097 */ 098 @Override 099 public String toString() { 100 return "destroy workspace \"" + workspaceName() + "\""; 101 } 102 }