1 /* 2 * ModeShape (http://www.modeshape.org) 3 * See the COPYRIGHT.txt file distributed with this work for information 4 * regarding copyright ownership. Some portions may be licensed 5 * to Red Hat, Inc. under one or more contributor license agreements. 6 * See the AUTHORS.txt file in the distribution for a full listing of 7 * individual contributors. 8 * 9 * ModeShape is free software. Unless otherwise indicated, all code in ModeShape 10 * is licensed to you under the terms of the GNU Lesser General Public License as 11 * published by the Free Software Foundation; either version 2.1 of 12 * the License, or (at your option) any later version. 13 * 14 * ModeShape is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this software; if not, write to the Free 21 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 22 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 23 */ 24 package org.modeshape.graph.connector.inmemory; 25 26 import java.util.List; 27 import java.util.Map; 28 import java.util.UUID; 29 import org.modeshape.graph.connector.base.MapNode; 30 import org.modeshape.graph.property.Name; 31 import org.modeshape.graph.property.Property; 32 import org.modeshape.graph.property.Path.Segment; 33 34 /** 35 * A specialization of the {@link MapNode}. 36 */ 37 public class InMemoryNode extends MapNode { 38 39 private static final long serialVersionUID = 1L; 40 41 /** 42 * Create a new in-memory node. 43 * 44 * @param uuid the desired UUID; never null 45 * @param name the name of the new node; may be null if the name is not known and there is no parent 46 * @param parent the UUID of the parent node; may be null if this is the root node and there is no name 47 * @param properties the properties; may be null if there are no properties 48 * @param children the list of child nodes; may be null 49 */ 50 public InMemoryNode( UUID uuid, 51 Segment name, 52 UUID parent, 53 Map<Name, Property> properties, 54 List<UUID> children ) { 55 super(uuid, name, parent, properties, children); 56 } 57 58 /** 59 * Create a new in-memory node. 60 * 61 * @param uuid the desired UUID; never null 62 * @param name the name of the new node; may be null if the name is not known and there is no parent 63 * @param parent the UUID of the parent node; may be null if this is the root node and there is no name 64 * @param properties the properties; may be null if there are no properties 65 * @param children the list of child nodes; may be null 66 */ 67 public InMemoryNode( UUID uuid, 68 Segment name, 69 UUID parent, 70 Iterable<Property> properties, 71 List<UUID> children ) { 72 super(uuid, name, parent, properties, children); 73 } 74 75 /** 76 * Create a new in-memory node. 77 * 78 * @param uuid the desired UUID; never null 79 */ 80 public InMemoryNode( UUID uuid ) { 81 super(uuid); 82 } 83 84 /** 85 * {@inheritDoc} 86 * 87 * @see org.modeshape.graph.connector.base.MapNode#freeze() 88 */ 89 @Override 90 public InMemoryNode freeze() { 91 if (!hasChanges()) return this; 92 return new InMemoryNode(getUuid(), getName(), getParent(), changes.getUnmodifiableProperties(), 93 changes.getUnmodifiableChildren()); 94 } 95 96 /** 97 * {@inheritDoc} 98 * <p> 99 * This method never clones the {@link #hasChanges() changes}. 100 * </p> 101 * 102 * @see java.lang.Object#clone() 103 */ 104 @Override 105 public InMemoryNode clone() { 106 return new InMemoryNode(getUuid(), getName(), getParent(), getProperties(), getChildren()); 107 } 108 }