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 * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA 010 * is licensed 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.connector.federation.merge; 025 026 import org.jboss.dna.graph.Location; 027 import org.jboss.dna.graph.request.ReadNodeRequest; 028 029 /** 030 * An in-memory (and temporary) representation of a federated node and it's merged properties and children. 031 * 032 * @author Randall Hauch 033 */ 034 public class FederatedNode extends ReadNodeRequest { 035 036 private static final long serialVersionUID = 1L; 037 038 private MergePlan mergePlan; 039 040 /** 041 * Create a federated node given the path and UUID. 042 * 043 * @param location the location of the federated node; may not be null 044 * @param workspaceName the name of the (federated) workspace in which this node exists 045 */ 046 public FederatedNode( Location location, 047 String workspaceName ) { 048 super(location, workspaceName); 049 super.setActualLocationOfNode(location); 050 } 051 052 /** 053 * Get the merge plan for this federated node 054 * 055 * @return the merge plan, or null if there is no merge plan 056 */ 057 public MergePlan getMergePlan() { 058 return mergePlan; 059 } 060 061 /** 062 * Set the merge plan for this federated node 063 * 064 * @param mergePlan the new merge plan for this federated node; may be null 065 */ 066 public void setMergePlan( MergePlan mergePlan ) { 067 this.mergePlan = mergePlan; 068 } 069 070 /** 071 * {@inheritDoc} 072 * 073 * @see java.lang.Object#hashCode() 074 */ 075 @Override 076 public int hashCode() { 077 return this.at().hashCode(); 078 } 079 080 /** 081 * {@inheritDoc} 082 * 083 * @see java.lang.Object#equals(java.lang.Object) 084 */ 085 @Override 086 public boolean equals( Object obj ) { 087 if (obj == this) return true; 088 if (obj instanceof FederatedNode) { 089 FederatedNode that = (FederatedNode)obj; 090 if (!this.at().equals(that.at())) return false; 091 if (!this.inWorkspace().equals(that.inWorkspace())) return false; 092 return true; 093 } 094 return false; 095 } 096 097 /** 098 * {@inheritDoc} 099 * 100 * @see java.lang.Object#toString() 101 */ 102 @Override 103 public String toString() { 104 return at().toString(); 105 } 106 }