| 1 | |
package org.kuali.rice.krms.api.repository.agenda; |
| 2 | |
|
| 3 | |
import java.io.Serializable; |
| 4 | |
|
| 5 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 6 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 7 | |
import javax.xml.bind.annotation.XmlElement; |
| 8 | |
import javax.xml.bind.annotation.XmlRootElement; |
| 9 | |
import javax.xml.bind.annotation.XmlType; |
| 10 | |
|
| 11 | |
import org.apache.commons.lang.StringUtils; |
| 12 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
| 13 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
| 14 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
| 15 | |
import org.kuali.rice.core.api.CoreConstants; |
| 16 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
| 17 | |
import org.kuali.rice.core.api.mo.ModelObjectComplete; |
| 18 | |
import org.kuali.rice.krms.api.repository.BaseAttribute; |
| 19 | |
import org.kuali.rice.krms.api.repository.BaseAttribute.Builder; |
| 20 | |
import org.kuali.rice.krms.api.repository.BaseAttribute.Elements; |
| 21 | |
import org.kuali.rice.krms.api.repository.type.KrmsAttributeDefinition; |
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
@XmlRootElement(name = AgendaAttribute.Constants.ROOT_ELEMENT_NAME) |
| 30 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 31 | |
@XmlType(name = AgendaAttribute.Constants.TYPE_NAME, propOrder = { |
| 32 | |
AgendaAttribute.Elements.ID, |
| 33 | |
AgendaAttribute.Elements.AGENDA_ID, |
| 34 | |
AgendaAttribute.Elements.ATTR_DEFN_ID, |
| 35 | |
AgendaAttribute.Elements.VALUE, |
| 36 | |
AgendaAttribute.Elements.ATTR_DEFN, |
| 37 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 38 | |
}) |
| 39 | 0 | public final class AgendaAttribute extends BaseAttribute implements AgendaAttributeContract, ModelObjectComplete { |
| 40 | |
private static final long serialVersionUID = 2988399046412505534L; |
| 41 | |
|
| 42 | |
@XmlElement(name = Elements.AGENDA_ID, required=true) |
| 43 | |
private String agendaId; |
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
private AgendaAttribute() { |
| 49 | 0 | super(); |
| 50 | 0 | this.agendaId = null; |
| 51 | 0 | } |
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
private AgendaAttribute(Builder builder) { |
| 60 | 0 | super(builder); |
| 61 | 0 | this.agendaId = builder.getAgendaId(); |
| 62 | 0 | } |
| 63 | |
|
| 64 | |
@Override |
| 65 | |
public String getAgendaId() { |
| 66 | 0 | return this.agendaId; |
| 67 | |
} |
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | 0 | public static class Builder extends BaseAttribute.Builder implements AgendaAttributeContract, ModelBuilder, Serializable { |
| 73 | |
private static final long serialVersionUID = -8619106871420999876L; |
| 74 | |
|
| 75 | |
private String agendaId; |
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
private Builder(String id, String agendaId, String attributeDefinitionId, String value) { |
| 81 | 0 | super(id, attributeDefinitionId, value); |
| 82 | 0 | setAgendaId(agendaId); |
| 83 | 0 | } |
| 84 | |
|
| 85 | |
public Builder attributeDefinition(KrmsAttributeDefinition.Builder attributeDefinition){ |
| 86 | 0 | setAttributeDefinition(attributeDefinition); |
| 87 | 0 | return this; |
| 88 | |
} |
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
public static Builder create(String id, String agendaId, String attributeDefinitionId, String value) { |
| 101 | 0 | return new Builder(id, agendaId, attributeDefinitionId, value); |
| 102 | |
} |
| 103 | |
|
| 104 | |
public static Builder create(AgendaAttributeContract contract){ |
| 105 | 0 | if (contract == null) { |
| 106 | 0 | throw new IllegalArgumentException("contract is null"); |
| 107 | |
} |
| 108 | 0 | Builder builder = new Builder(contract.getId(), |
| 109 | |
contract.getAgendaId(), |
| 110 | |
contract.getAttributeDefinitionId(), |
| 111 | |
contract.getValue()); |
| 112 | 0 | if (contract.getAttributeDefinition() != null){ |
| 113 | 0 | KrmsAttributeDefinition.Builder attrBuilder = |
| 114 | |
KrmsAttributeDefinition.Builder.create(contract.getAttributeDefinition()); |
| 115 | 0 | builder.setAttributeDefinition(attrBuilder); |
| 116 | |
} |
| 117 | 0 | return builder; |
| 118 | |
} |
| 119 | |
|
| 120 | |
public void setAgendaId(String agendaId) { |
| 121 | 0 | if (StringUtils.isBlank(agendaId)) { |
| 122 | 0 | throw new IllegalArgumentException("AgendaId is blank"); |
| 123 | |
} |
| 124 | 0 | this.agendaId = agendaId; |
| 125 | 0 | } |
| 126 | |
|
| 127 | |
@Override |
| 128 | |
public String getAgendaId() { |
| 129 | 0 | return agendaId; |
| 130 | |
} |
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | |
@Override |
| 138 | |
public AgendaAttribute build() { |
| 139 | 0 | return new AgendaAttribute(this); |
| 140 | |
} |
| 141 | |
|
| 142 | |
} |
| 143 | |
|
| 144 | |
@Override |
| 145 | |
public int hashCode() { |
| 146 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
| 147 | |
} |
| 148 | |
|
| 149 | |
@Override |
| 150 | |
public boolean equals(Object obj) { |
| 151 | 0 | return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
| 152 | |
} |
| 153 | |
|
| 154 | |
@Override |
| 155 | |
public String toString() { |
| 156 | 0 | return ToStringBuilder.reflectionToString(this); |
| 157 | |
} |
| 158 | |
|
| 159 | |
|
| 160 | |
|
| 161 | |
|
| 162 | 0 | static class Constants { |
| 163 | |
final static String ROOT_ELEMENT_NAME = "AgendaAttribute"; |
| 164 | |
final static String TYPE_NAME = "AgendaAttributeType"; |
| 165 | 0 | final static String[] HASH_CODE_EQUALS_EXCLUDE = { "_elements" }; |
| 166 | |
} |
| 167 | |
|
| 168 | |
|
| 169 | |
|
| 170 | |
|
| 171 | |
|
| 172 | 0 | public static class Elements extends BaseAttribute.Elements { |
| 173 | |
final static String AGENDA_ID = "agendaId"; |
| 174 | |
} |
| 175 | |
} |