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.jcr.cache;
025    
026    import java.util.Iterator;
027    import java.util.UUID;
028    import net.jcip.annotations.Immutable;
029    import org.jboss.dna.common.collection.EmptyIterator;
030    import org.jboss.dna.graph.property.Name;
031    import org.jboss.dna.graph.property.PathFactory;
032    import org.jboss.dna.graph.property.Path.Segment;
033    
034    /**
035     * An immutable implementation of {@link Children}.
036     */
037    @Immutable
038    public final class EmptyChildren implements Children, InternalChildren {
039    
040        static final Iterator<ChildNode> EMPTY_ITERATOR = new EmptyIterator<ChildNode>();
041    
042        private final UUID parentUuid;
043    
044        public EmptyChildren( UUID parentUuid ) {
045            this.parentUuid = parentUuid;
046        }
047    
048        /**
049         * {@inheritDoc}
050         * 
051         * @see org.jboss.dna.jcr.cache.Children#size()
052         */
053        public int size() {
054            return 0;
055        }
056    
057        /**
058         * {@inheritDoc}
059         * 
060         * @see java.lang.Iterable#iterator()
061         */
062        public Iterator<ChildNode> iterator() {
063            return EMPTY_ITERATOR;
064        }
065    
066        /**
067         * {@inheritDoc}
068         * 
069         * @see org.jboss.dna.jcr.cache.Children#getParentUuid()
070         */
071        public UUID getParentUuid() {
072            return parentUuid;
073        }
074    
075        /**
076         * {@inheritDoc}
077         * 
078         * @see org.jboss.dna.jcr.cache.Children#getChild(java.util.UUID)
079         */
080        public ChildNode getChild( UUID uuid ) {
081            return null;
082        }
083    
084        /**
085         * {@inheritDoc}
086         * 
087         * @see org.jboss.dna.jcr.cache.Children#getChild(org.jboss.dna.graph.property.Path.Segment)
088         */
089        public ChildNode getChild( Segment segment ) {
090            return null;
091        }
092    
093        /**
094         * {@inheritDoc}
095         * 
096         * @see org.jboss.dna.jcr.cache.Children#getChildren(org.jboss.dna.graph.property.Name)
097         */
098        public Iterator<ChildNode> getChildren( Name name ) {
099            return EMPTY_ITERATOR;
100        }
101    
102        /**
103         * {@inheritDoc}
104         * 
105         * @see org.jboss.dna.jcr.cache.Children#getCountOfSameNameSiblingsWithName(org.jboss.dna.graph.property.Name)
106         */
107        public int getCountOfSameNameSiblingsWithName( Name name ) {
108            return 0;
109        }
110    
111        /**
112         * {@inheritDoc}
113         * 
114         * @see org.jboss.dna.jcr.cache.InternalChildren#with(org.jboss.dna.graph.property.Name, java.util.UUID,
115         *      org.jboss.dna.graph.property.PathFactory)
116         */
117        public ChangedChildren with( Name newChildName,
118                                     UUID newChildUuid,
119                                     PathFactory pathFactory ) {
120            ChangedChildren result = new ChangedChildren(this);
121            result.add(newChildName, newChildUuid, pathFactory);
122            return result;
123        }
124    
125        /**
126         * {@inheritDoc}
127         * 
128         * @see org.jboss.dna.jcr.cache.InternalChildren#without(java.util.UUID, org.jboss.dna.graph.property.PathFactory)
129         */
130        public ChangedChildren without( UUID childUuid,
131                                        PathFactory pathFactory ) {
132            return new ChangedChildren(this.parentUuid);
133        }
134    
135        /**
136         * {@inheritDoc}
137         * 
138         * @see java.lang.Object#toString()
139         */
140        @Override
141        public String toString() {
142            return "";
143        }
144    }