001 /*
002 * JBoss, Home of Professional Open Source.
003 * Copyright 2008, Red Hat Middleware LLC, and individual contributors
004 * as indicated by the @author tags. See the copyright.txt file in the
005 * distribution for a full listing of individual contributors.
006 *
007 * This is free software; you can redistribute it and/or modify it
008 * under the terms of the GNU Lesser General Public License as
009 * published by the Free Software Foundation; either version 2.1 of
010 * the License, or (at your option) any later version.
011 *
012 * This software is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * You should have received a copy of the GNU Lesser General Public
018 * License along with this software; if not, write to the Free
019 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021 */
022 package org.jboss.dna.connector.federation.merge;
023
024 import java.util.UUID;
025 import org.jboss.dna.graph.Location;
026 import org.jboss.dna.graph.requests.ReadNodeRequest;
027
028 /**
029 * An in-memory (and temporary) representation of a federated node and it's merged properties and children.
030 *
031 * @author Randall Hauch
032 */
033 public class FederatedNode extends ReadNodeRequest {
034
035 private static final long serialVersionUID = 1L;
036
037 private UUID uuid;
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 uuid the UUID of the federated node; may not be null
045 */
046 public FederatedNode( Location location,
047 UUID uuid ) {
048 super(location);
049 assert uuid != null;
050 this.uuid = uuid;
051 super.setActualLocationOfNode(location);
052 }
053
054 /**
055 * Get the UUID for this federated node.
056 *
057 * @return the UUID; never null
058 */
059 public UUID getUuid() {
060 return uuid;
061 }
062
063 /**
064 * @param uuid Sets uuid to the specified value.
065 */
066 public void setUuid( UUID uuid ) {
067 this.uuid = uuid;
068 }
069
070 /**
071 * Get the merge plan for this federated node
072 *
073 * @return the merge plan, or null if there is no merge plan
074 */
075 public MergePlan getMergePlan() {
076 return mergePlan;
077 }
078
079 /**
080 * Set the merge plan for this federated node
081 *
082 * @param mergePlan the new merge plan for this federated node; may be null
083 */
084 public void setMergePlan( MergePlan mergePlan ) {
085 this.mergePlan = mergePlan;
086 }
087
088 /**
089 * {@inheritDoc}
090 *
091 * @see java.lang.Object#hashCode()
092 */
093 @Override
094 public int hashCode() {
095 return this.at().hashCode();
096 }
097
098 /**
099 * {@inheritDoc}
100 *
101 * @see java.lang.Object#equals(java.lang.Object)
102 */
103 @Override
104 public boolean equals( Object obj ) {
105 if (obj == this) return true;
106 if (obj instanceof FederatedNode) {
107 FederatedNode that = (FederatedNode)obj;
108 if (this.at().equals(that.at())) return true;
109 if (this.getUuid().equals(that.getUuid())) return true;
110 }
111 return false;
112 }
113
114 /**
115 * {@inheritDoc}
116 *
117 * @see java.lang.Object#toString()
118 */
119 @Override
120 public String toString() {
121 return at().toString();
122 }
123 }