001/** 002 * Copyright 2005-2015 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krms.api.repository.agenda; 017 018import java.io.Serializable; 019import java.util.Collection; 020 021import javax.xml.bind.annotation.XmlAccessType; 022import javax.xml.bind.annotation.XmlAccessorType; 023import javax.xml.bind.annotation.XmlAnyElement; 024import javax.xml.bind.annotation.XmlElement; 025import javax.xml.bind.annotation.XmlRootElement; 026import javax.xml.bind.annotation.XmlType; 027 028import org.kuali.rice.core.api.CoreConstants; 029import org.kuali.rice.core.api.mo.AbstractDataTransferObject; 030import org.kuali.rice.core.api.mo.ModelBuilder; 031 032/** 033 * Concrete model object implementation of KRMS Repository AgendaTreeSubAgendaEntry 034 * immutable. 035 * Instances of Agenda can be (un)marshalled to and from XML. 036 * 037 * @author Kuali Rice Team (rice.collab@kuali.org) 038 * 039 */ 040@XmlRootElement(name = AgendaTreeSubAgendaEntry.Constants.ROOT_ELEMENT_NAME) 041@XmlAccessorType(XmlAccessType.NONE) 042@XmlType(name = AgendaTreeSubAgendaEntry.Constants.TYPE_NAME, propOrder = { 043 AgendaTreeSubAgendaEntry.Elements.AGENDA_ITEM_ID, 044 AgendaTreeSubAgendaEntry.Elements.SUB_AGENDA_ID, 045 CoreConstants.CommonElements.FUTURE_ELEMENTS 046}) 047public final class AgendaTreeSubAgendaEntry extends AbstractDataTransferObject implements AgendaTreeEntryDefinitionContract { 048 049 private static final long serialVersionUID = 8594116503548506936L; 050 051 @XmlElement(name = Elements.AGENDA_ITEM_ID, required = true) 052 private final String agendaItemId; 053 054 @XmlElement(name = Elements.SUB_AGENDA_ID, required = true) 055 private final String subAgendaId; 056 057 @SuppressWarnings("unused") 058 @XmlAnyElement 059 private final Collection<org.w3c.dom.Element> _futureElements = null; 060 061 /** 062 * This constructor should never be called. 063 * It is only present for use during JAXB unmarshalling. 064 */ 065 private AgendaTreeSubAgendaEntry() { 066 this.agendaItemId = null; 067 this.subAgendaId = null; 068 } 069 070 /** 071 * Constructs a AgendaTreeSubAgendaEntry from the given builder. 072 * This constructor is private and should only ever be invoked from the builder. 073 * 074 * @param builder the Builder from which to construct the AgendaTreeSubAgendaEntry 075 */ 076 private AgendaTreeSubAgendaEntry(Builder builder) { 077 this.agendaItemId = builder.getAgendaItemId(); 078 this.subAgendaId = builder.getSubAgendaId(); 079 } 080 081 @Override 082 public String getAgendaItemId() { 083 return agendaItemId; 084 } 085 086 /** 087 * Returns the subAgendId 088 * @return subAgendaId 089 */ 090 public String getSubAgendaId() { 091 return this.subAgendaId; 092 } 093 094 /** 095 * This builder is used to construct instances of AgendaTreeSubAgendaEntry. 096 */ 097 public static class Builder implements ModelBuilder, Serializable { 098 099 private static final long serialVersionUID = 3548736700798501429L; 100 101 private String agendaItemId; 102 private String subAgendaId; 103 104 /** 105 * Private constructor for creating a builder with all of it's required attributes. 106 * @param agendaItemId to set the agendaItemId value to, must not be null 107 * @param subAgendaId to set the subAgendaId value to, must not be null 108 */ 109 private Builder(String agendaItemId, String subAgendaId) { 110 setAgendaItemId(agendaItemId); 111 setSubAgendaId(subAgendaId); 112 } 113 114 /** 115 * Create a builder using the given values 116 * 117 * @param agendaItemId to set the agendaItemId value to, must not be null 118 * @param subAgendaId to set the subAgendaId value to, must not be null 119 * @return Builder with the given values set 120 */ 121 public static Builder create(String agendaItemId, String subAgendaId){ 122 return new Builder(agendaItemId, subAgendaId); 123 } 124 125 /** 126 * Returns the agendaItemId 127 * @return the agendaItemId of the builder 128 */ 129 public String getAgendaItemId() { 130 return this.agendaItemId; 131 } 132 133 /** 134 * Returns the subAgendaId 135 * @return the subAgendaId of the builder 136 */ 137 public String getSubAgendaId() { 138 return this.subAgendaId; 139 } 140 141 /** 142 * Sets the agendaItemId of the builder, cannot be null 143 * @param agendaItemId to set the value of the agendaItemId to, must not be null 144 * @throws IllegalArgumentException if the agendaItemId is null 145 */ 146 public void setAgendaItemId(String agendaItemId) { 147 if (agendaItemId == null) { 148 throw new IllegalArgumentException("agendaItemId was null"); 149 } 150 this.agendaItemId = agendaItemId; 151 } 152 153 /** 154 * Sets the subAgendaId of the builder, cannot be null 155 * @param subAgendaId to set the subAgendaId value to, must not be null 156 * @throws IllegalArgumentException if the subAgendaId is null 157 */ 158 public void setSubAgendaId(String subAgendaId) { 159 if (subAgendaId == null) { 160 throw new IllegalArgumentException("subAgendaId was null"); 161 } 162 this.subAgendaId = subAgendaId; 163 } 164 165 @Override 166 public AgendaTreeSubAgendaEntry build() { 167 return new AgendaTreeSubAgendaEntry(this); 168 } 169 170 } 171 172 /** 173 * Defines some internal constants used on this class. 174 */ 175 static class Constants { 176 final static String ROOT_ELEMENT_NAME = "agendaTreeSubAgendaEntry"; 177 final static String TYPE_NAME = "AgendaTreeSubAgendaEntryType"; 178 } 179 180 /** 181 * A private class which exposes constants which define the XML element names to use 182 * when this object is marshalled to XML. 183 */ 184 static class Elements { 185 final static String AGENDA_ITEM_ID = "agendaItemId"; 186 final static String SUB_AGENDA_ID = "subAgendaId"; 187 } 188 189}