1 /* 2 * Copyright (C) 2016 Uwe Plonus 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 package org.sw4j.tool.annotation.jpa.generator.model; 18 19 import java.util.Collections; 20 import java.util.LinkedList; 21 import java.util.List; 22 import javax.annotation.Nonnull; 23 import javax.xml.bind.annotation.XmlAccessType; 24 import javax.xml.bind.annotation.XmlAccessorType; 25 import javax.xml.bind.annotation.XmlElement; 26 import javax.xml.bind.annotation.XmlRootElement; 27 import javax.xml.bind.annotation.XmlType; 28 29 /** 30 * This is a model that contains all elements needed to create a schema for JPA entities. 31 * 32 * @author Uwe Plonus 33 */ 34 @XmlAccessorType(XmlAccessType.NONE) 35 @XmlRootElement(name = "model") 36 @XmlType(name = "", 37 propOrder = { 38 "entities", 39 }) 40 public class Model { 41 42 /** The entities of the model. */ 43 private final List<Entity> entities; 44 45 /** 46 * Default constructor. 47 */ 48 public Model() { 49 entities = new LinkedList<>(); 50 } 51 52 /** 53 * Adds an entity to the model. 54 * 55 * @param entity the entity to add. 56 */ 57 public void addEntity(@Nonnull final Entity entity) { 58 entities.add(entity); 59 } 60 61 /** 62 * Returns all entities of the model. 63 * 64 * @return a list containing all elements of the model. 65 */ 66 @XmlElement(name = "entity") 67 public List<Entity> getEntities() { 68 return Collections.unmodifiableList(entities); 69 } 70 71 }