001 /* 002 * Copyright 2005-2009, 2011 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 */ 016 package org.kuali.rice.kew.api.document; 017 018 import java.io.Serializable; 019 import java.util.Collection; 020 021 import javax.xml.bind.annotation.XmlAccessType; 022 import javax.xml.bind.annotation.XmlAccessorType; 023 import javax.xml.bind.annotation.XmlAnyElement; 024 import javax.xml.bind.annotation.XmlElement; 025 import javax.xml.bind.annotation.XmlRootElement; 026 import javax.xml.bind.annotation.XmlType; 027 028 import org.apache.commons.lang.StringUtils; 029 import org.apache.commons.lang.builder.EqualsBuilder; 030 import org.apache.commons.lang.builder.HashCodeBuilder; 031 import org.apache.commons.lang.builder.ToStringBuilder; 032 import org.kuali.rice.core.api.CoreConstants; 033 import org.w3c.dom.Element; 034 035 /** 036 * TODO... 037 */ 038 @XmlRootElement(name = WorkflowAttributeValidationError.Constants.ROOT_ELEMENT_NAME) 039 @XmlAccessorType(XmlAccessType.NONE) 040 @XmlType(name = WorkflowAttributeValidationError.Constants.TYPE_NAME, propOrder = { 041 WorkflowAttributeValidationError.Elements.KEY, 042 WorkflowAttributeValidationError.Elements.MESSAGE, 043 CoreConstants.CommonElements.FUTURE_ELEMENTS 044 }) 045 public final class WorkflowAttributeValidationError implements Serializable { 046 047 private static final long serialVersionUID = 3323649177455266977L; 048 049 @XmlElement(name = Elements.KEY, required = true) 050 private final String key; 051 052 @XmlElement(name = Elements.MESSAGE, required = true) 053 private final String message; 054 055 @SuppressWarnings("unused") 056 @XmlAnyElement 057 private final Collection<Element> _futureElements = null; 058 059 /** 060 * Private constructor used only by JAXB. 061 */ 062 public WorkflowAttributeValidationError() { 063 this.key = null; 064 this.message = null; 065 } 066 067 private WorkflowAttributeValidationError(String key, String message) { 068 if (StringUtils.isBlank(key)) { 069 throw new IllegalArgumentException("key was null or blank"); 070 } 071 if (StringUtils.isBlank(message)) { 072 throw new IllegalArgumentException("message was null or blank"); 073 } 074 this.key = key; 075 this.message = message; 076 } 077 078 public static WorkflowAttributeValidationError create(String key, String message) { 079 return new WorkflowAttributeValidationError(key, message); 080 } 081 082 public String getKey() { 083 return key; 084 } 085 086 public String getMessage() { 087 return message; 088 } 089 090 @Override 091 public int hashCode() { 092 return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); 093 } 094 095 @Override 096 public boolean equals(Object object) { 097 return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE); 098 } 099 100 @Override 101 public String toString() { 102 return ToStringBuilder.reflectionToString(this); 103 } 104 105 /** 106 * Defines some internal constants used on this class. 107 */ 108 static class Constants { 109 final static String ROOT_ELEMENT_NAME = "workflowAttributeValidationError"; 110 final static String TYPE_NAME = "WorkflowAttributeValidationErrorType"; 111 final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[]{CoreConstants.CommonElements.FUTURE_ELEMENTS}; 112 } 113 114 /** 115 * A private class which exposes constants which define the XML element names to use when this 116 * object is marshalled to XML. 117 */ 118 static class Elements { 119 final static String KEY = "key"; 120 final static String MESSAGE = "message"; 121 } 122 123 124 }