001    package org.andromda.core.configuration;
002    
003    import java.io.Serializable;
004    import java.util.ArrayList;
005    import java.util.Collection;
006    
007    /**
008     * Stores the repository information for each model that AndroMDA will process.
009     *
010     * @author Chad Brandon
011     */
012    public class Repository
013        implements Serializable
014    {
015        private static final long serialVersionUID = 34L;
016    
017        /**
018         * Stores the unique name of this repository.
019         */
020        private String name;
021    
022        /**
023         * Sets the unique (among other repositories)
024         * name.
025         *
026         * @param name the unique name of this repository.
027         */
028        public void setName(final String name)
029        {
030            this.name = name;
031        }
032    
033        /**
034         * Gets the unique name of this repository.
035         *
036         * @return the repository name.
037         */
038        public String getName()
039        {
040            return this.name;
041        }
042    
043        /**
044         * The models loaded by this repository.
045         */
046        private final Collection<Model> models = new ArrayList<Model>();
047    
048        /**
049         * Adds a model that this repository will load.
050         *
051         * @param model the model to load.
052         */
053        public void addModel(final Model model)
054        {
055            model.setRepository(this);
056            this.models.add(model);
057        }
058    
059        /**
060         * Gets the model instances belonging to this repository.
061         *
062         * @return the of model instances.
063         */
064        public Model[] getModels()
065        {
066            return this.models.toArray(new Model[this.models.size()]);
067        }
068    }