| 1 | |
package org.kuali.rice.krms.api.repository.action; |
| 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.type.KrmsAttributeDefinition; |
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
@XmlRootElement(name = ActionAttribute.Constants.ROOT_ELEMENT_NAME) |
| 28 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 29 | |
@XmlType(name = ActionAttribute.Constants.TYPE_NAME, propOrder = { |
| 30 | |
ActionAttribute.Elements.ID, |
| 31 | |
ActionAttribute.Elements.ACTION_ID, |
| 32 | |
ActionAttribute.Elements.ATTR_DEFN_ID, |
| 33 | |
ActionAttribute.Elements.VALUE, |
| 34 | |
ActionAttribute.Elements.ACTION_TYPE_ID, |
| 35 | |
ActionAttribute.Elements.ATTR_DEFN, |
| 36 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 37 | |
}) |
| 38 | 4 | public final class ActionAttribute extends BaseAttribute implements ActionAttributeContract, ModelObjectComplete { |
| 39 | |
private static final long serialVersionUID = -6126133049308968098L; |
| 40 | |
|
| 41 | |
@XmlElement(name = ActionAttribute.Elements.ACTION_ID, required=true) |
| 42 | |
private final String actionId; |
| 43 | |
@XmlElement(name = Elements.ACTION_TYPE_ID, required=true) |
| 44 | |
private final String actionTypeId; |
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
private ActionAttribute() { |
| 50 | 5 | super(); |
| 51 | 5 | this.actionId = null; |
| 52 | 5 | this.actionTypeId = null; |
| 53 | 5 | } |
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
private ActionAttribute(Builder builder) { |
| 62 | 4 | super(builder); |
| 63 | 4 | this.actionId = builder.getActionId(); |
| 64 | 4 | this.actionTypeId = builder.getActionTypeId(); |
| 65 | 4 | } |
| 66 | |
|
| 67 | |
@Override |
| 68 | |
public String getActionId() { |
| 69 | 0 | return this.actionId; |
| 70 | |
} |
| 71 | |
|
| 72 | |
@Override |
| 73 | |
public String getActionTypeId() { |
| 74 | 0 | return this.actionTypeId; |
| 75 | |
} |
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | 1 | public static class Builder extends BaseAttribute.Builder implements ActionAttributeContract, ModelBuilder, Serializable { |
| 81 | |
private static final long serialVersionUID = 5799994031051731535L; |
| 82 | |
|
| 83 | |
private String actionId; |
| 84 | |
private String actionTypeId; |
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
private Builder(String id, String actionId, String attributeDefinitionId, String actionTypeId, String value) { |
| 90 | 4 | super(id, attributeDefinitionId, value); |
| 91 | 4 | setActionId(actionId); |
| 92 | 4 | setActionTypeId(actionTypeId); |
| 93 | 4 | setValue(value); |
| 94 | 4 | } |
| 95 | |
|
| 96 | |
public Builder attributeDefinition(KrmsAttributeDefinition.Builder attributeDefinition){ |
| 97 | 0 | setAttributeDefinition(attributeDefinition); |
| 98 | 0 | return this; |
| 99 | |
} |
| 100 | |
|
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
public static Builder create(String id, String actionId, String attributeDefinitionId, String actionTypeId, String value) { |
| 112 | 4 | return new Builder(id, actionId, attributeDefinitionId, actionTypeId, value); |
| 113 | |
} |
| 114 | |
|
| 115 | |
public static Builder create(ActionAttributeContract contract){ |
| 116 | 0 | if (contract == null) { |
| 117 | 0 | throw new IllegalArgumentException("contract is null"); |
| 118 | |
} |
| 119 | 0 | Builder builder = new Builder(contract.getId(), |
| 120 | |
contract.getActionId(), |
| 121 | |
contract.getAttributeDefinitionId(), |
| 122 | |
contract.getValue(), |
| 123 | |
contract.getActionTypeId()); |
| 124 | 0 | if (contract.getAttributeDefinition() != null) { |
| 125 | 0 | KrmsAttributeDefinition.Builder attrBuilder = |
| 126 | |
KrmsAttributeDefinition.Builder.create(contract.getAttributeDefinition()); |
| 127 | 0 | builder.setAttributeDefinition(attrBuilder); |
| 128 | |
} |
| 129 | 0 | return builder; |
| 130 | |
} |
| 131 | |
|
| 132 | |
public void setActionId(String actionId) { |
| 133 | 4 | if (StringUtils.isBlank(actionId)) { |
| 134 | 0 | throw new IllegalArgumentException("actionId is blank"); |
| 135 | |
} |
| 136 | 4 | this.actionId = actionId; |
| 137 | 4 | } |
| 138 | |
|
| 139 | |
public void setActionTypeId(String actionTypeId) { |
| 140 | 4 | this.actionTypeId = actionTypeId; |
| 141 | 4 | } |
| 142 | |
|
| 143 | |
@Override |
| 144 | |
public String getActionId() { |
| 145 | 4 | return actionId; |
| 146 | |
} |
| 147 | |
|
| 148 | |
@Override |
| 149 | |
public String getActionTypeId() { |
| 150 | 4 | return actionTypeId; |
| 151 | |
} |
| 152 | |
|
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
|
| 157 | |
|
| 158 | |
@Override |
| 159 | |
public ActionAttribute build() { |
| 160 | 4 | return new ActionAttribute(this); |
| 161 | |
} |
| 162 | |
|
| 163 | |
} |
| 164 | |
@Override |
| 165 | |
public int hashCode() { |
| 166 | 7 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
| 167 | |
} |
| 168 | |
|
| 169 | |
@Override |
| 170 | |
public boolean equals(Object obj) { |
| 171 | 2 | return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
| 172 | |
} |
| 173 | |
|
| 174 | |
@Override |
| 175 | |
public String toString() { |
| 176 | 0 | return ToStringBuilder.reflectionToString(this); |
| 177 | |
} |
| 178 | |
|
| 179 | |
|
| 180 | |
|
| 181 | |
|
| 182 | 0 | static class Constants { |
| 183 | |
final static String ROOT_ELEMENT_NAME = "ActionAttribute"; |
| 184 | |
final static String TYPE_NAME = "ActionAttributeType"; |
| 185 | 1 | final static String[] HASH_CODE_EQUALS_EXCLUDE = { CoreConstants.CommonElements.FUTURE_ELEMENTS }; |
| 186 | |
} |
| 187 | |
|
| 188 | |
|
| 189 | |
|
| 190 | |
|
| 191 | |
|
| 192 | 0 | public static class Elements extends BaseAttribute.Elements { |
| 193 | |
final static String ACTION_ID = "actionId"; |
| 194 | |
final static String ACTION_TYPE_ID = "actionTypeId"; |
| 195 | |
} |
| 196 | |
} |