| 1 | |
package org.kuali.rice.krms.api.repository.agenda; |
| 2 | |
|
| 3 | |
import java.io.Serializable; |
| 4 | |
import java.util.ArrayList; |
| 5 | |
import java.util.Collection; |
| 6 | |
import java.util.Collections; |
| 7 | |
import java.util.List; |
| 8 | |
|
| 9 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 10 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 11 | |
import javax.xml.bind.annotation.XmlAnyElement; |
| 12 | |
import javax.xml.bind.annotation.XmlElement; |
| 13 | |
import javax.xml.bind.annotation.XmlElements; |
| 14 | |
import javax.xml.bind.annotation.XmlRootElement; |
| 15 | |
import javax.xml.bind.annotation.XmlType; |
| 16 | |
|
| 17 | |
import org.apache.commons.lang.StringUtils; |
| 18 | |
import org.kuali.rice.core.api.CoreConstants; |
| 19 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
| 20 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
@XmlRootElement(name = AgendaTreeDefinition.Constants.ROOT_ELEMENT_NAME) |
| 30 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 31 | |
@XmlType(name = AgendaTreeDefinition.Constants.TYPE_NAME, propOrder = { |
| 32 | |
AgendaTreeDefinition.Elements.AGENDA_ID, |
| 33 | |
AgendaTreeDefinition.Elements.ENTRIES, |
| 34 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 35 | |
}) |
| 36 | 16 | public final class AgendaTreeDefinition extends AbstractDataTransferObject { |
| 37 | |
|
| 38 | |
private static final long serialVersionUID = 3355519740298280591L; |
| 39 | |
|
| 40 | |
@XmlElement(name = Elements.AGENDA_ID, required = false) |
| 41 | |
private final String agendaId; |
| 42 | |
|
| 43 | |
@XmlElements(value = { |
| 44 | |
@XmlElement(name = Elements.RULE, type = AgendaTreeRuleEntry.class, required = false), |
| 45 | |
@XmlElement(name = Elements.SUB_AGENDA, type = AgendaTreeSubAgendaEntry.class, required = false) |
| 46 | |
}) |
| 47 | |
private final List<AgendaTreeEntryDefinition> entries; |
| 48 | |
|
| 49 | 49 | @SuppressWarnings("unused") |
| 50 | |
@XmlAnyElement |
| 51 | |
private final Collection<org.w3c.dom.Element> _futureElements = null; |
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | 33 | private AgendaTreeDefinition() { |
| 58 | 33 | this.agendaId = null; |
| 59 | 33 | this.entries = null; |
| 60 | 33 | } |
| 61 | |
|
| 62 | 16 | private AgendaTreeDefinition(Builder builder) { |
| 63 | 16 | this.agendaId = builder.getAgendaId(); |
| 64 | 16 | this.entries = builder.getEntries(); |
| 65 | 16 | } |
| 66 | |
|
| 67 | |
public String getAgendaId() { |
| 68 | 5 | return agendaId; |
| 69 | |
} |
| 70 | |
|
| 71 | |
public List<AgendaTreeEntryDefinition> getEntries() { |
| 72 | 25 | if (entries == null){ |
| 73 | 0 | return Collections.emptyList(); |
| 74 | |
} |
| 75 | 25 | return Collections.unmodifiableList(entries); |
| 76 | |
} |
| 77 | |
|
| 78 | 6 | public static class Builder implements ModelBuilder, Serializable { |
| 79 | |
|
| 80 | |
private static final long serialVersionUID = 7981215392039022620L; |
| 81 | |
|
| 82 | |
private String agendaId; |
| 83 | |
private List<AgendaTreeEntryDefinition> entries; |
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | 26 | private Builder() { |
| 89 | 26 | this.entries = new ArrayList<AgendaTreeEntryDefinition>(); |
| 90 | 26 | } |
| 91 | |
|
| 92 | |
public static Builder create(){ |
| 93 | 26 | return new Builder(); |
| 94 | |
} |
| 95 | |
|
| 96 | |
public void setAgendaId(String agendaId) { |
| 97 | 22 | if (StringUtils.isBlank(agendaId)) { |
| 98 | 3 | throw new IllegalArgumentException("agendaItemId was null or blank"); |
| 99 | |
} |
| 100 | 19 | this.agendaId = agendaId; |
| 101 | 19 | } |
| 102 | |
|
| 103 | |
public void addRuleEntry(AgendaTreeRuleEntry ruleEntry) { |
| 104 | 20 | if (ruleEntry == null) { |
| 105 | 1 | throw new IllegalArgumentException("ruleEntry was null"); |
| 106 | |
} |
| 107 | 19 | entries.add(ruleEntry); |
| 108 | 19 | } |
| 109 | |
|
| 110 | |
public void addSubAgendaEntry(AgendaTreeSubAgendaEntry subAgendaEntry) { |
| 111 | 2 | if (subAgendaEntry == null) { |
| 112 | 1 | throw new IllegalArgumentException("subAgendaEntry was null"); |
| 113 | |
} |
| 114 | 1 | entries.add(subAgendaEntry); |
| 115 | 1 | } |
| 116 | |
|
| 117 | |
public String getAgendaId() { |
| 118 | 16 | return this.agendaId; |
| 119 | |
} |
| 120 | |
|
| 121 | |
public List<AgendaTreeEntryDefinition> getEntries() { |
| 122 | 16 | return this.entries; |
| 123 | |
} |
| 124 | |
|
| 125 | |
@Override |
| 126 | |
public AgendaTreeDefinition build() { |
| 127 | 16 | return new AgendaTreeDefinition(this); |
| 128 | |
} |
| 129 | |
|
| 130 | |
} |
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | 0 | static class Constants { |
| 136 | |
final static String ROOT_ELEMENT_NAME = "agendaTreeDefinition"; |
| 137 | |
final static String TYPE_NAME = "AgendaTreeDefinition"; |
| 138 | |
} |
| 139 | |
|
| 140 | |
|
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | 0 | static class Elements { |
| 145 | |
final static String AGENDA_ID = "agendaId"; |
| 146 | |
final static String ENTRIES = "entries"; |
| 147 | |
final static String RULE = "rule"; |
| 148 | |
final static String SUB_AGENDA = "subAgenda"; |
| 149 | |
} |
| 150 | |
|
| 151 | |
} |