|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  15 |     | 
     | 
  |  16 |     | 
     | 
  |  17 |     | 
   package org.kuali.rice.core.api.style;  | 
  |  18 |     | 
     | 
  |  19 |     | 
   import java.io.Serializable;  | 
  |  20 |     | 
   import java.util.Collection;  | 
  |  21 |     | 
     | 
  |  22 |     | 
   import javax.xml.bind.annotation.XmlAccessType;  | 
  |  23 |     | 
   import javax.xml.bind.annotation.XmlAccessorType;  | 
  |  24 |     | 
   import javax.xml.bind.annotation.XmlAnyElement;  | 
  |  25 |     | 
   import javax.xml.bind.annotation.XmlElement;  | 
  |  26 |     | 
   import javax.xml.bind.annotation.XmlRootElement;  | 
  |  27 |     | 
   import javax.xml.bind.annotation.XmlType;  | 
  |  28 |     | 
     | 
  |  29 |     | 
   import org.apache.commons.lang.StringUtils;  | 
  |  30 |     | 
   import org.apache.commons.lang.builder.EqualsBuilder;  | 
  |  31 |     | 
   import org.apache.commons.lang.builder.HashCodeBuilder;  | 
  |  32 |     | 
   import org.apache.commons.lang.builder.ToStringBuilder;  | 
  |  33 |     | 
   import org.kuali.rice.core.api.CoreConstants;  | 
  |  34 |     | 
   import org.kuali.rice.core.api.mo.ModelBuilder;  | 
  |  35 |     | 
   import org.kuali.rice.core.api.mo.ModelObjectComplete;  | 
  |  36 |     | 
   import org.w3c.dom.Element;  | 
  |  37 |     | 
     | 
  |  38 |     | 
     | 
  |  39 |     | 
     | 
  |  40 |     | 
     | 
  |  41 |     | 
     | 
  |  42 |     | 
     | 
  |  43 |     | 
     | 
  |  44 |     | 
     | 
  |  45 |     | 
     | 
  |  46 |     | 
   @XmlRootElement(name = Style.Constants.ROOT_ELEMENT_NAME)  | 
  |  47 |     | 
   @XmlAccessorType(XmlAccessType.NONE)  | 
  |  48 |     | 
   @XmlType(name = Style.Constants.TYPE_NAME, propOrder = { | 
  |  49 |     | 
                   Style.Elements.STYLE_ID,  | 
  |  50 |     | 
                   Style.Elements.NAME,  | 
  |  51 |     | 
                   Style.Elements.XML_CONTENT,  | 
  |  52 |     | 
                   Style.Elements.ACTIVE,  | 
  |  53 |     | 
           CoreConstants.CommonElements.VERSION_NUMBER,  | 
  |  54 |     | 
           CoreConstants.CommonElements.OBJECT_ID,  | 
  |  55 |     | 
           CoreConstants.CommonElements.FUTURE_ELEMENTS  | 
  |  56 |     | 
   })  | 
  |  57 |    0 |    public final class Style implements StyleContract, ModelObjectComplete { | 
  |  58 |     | 
     | 
  |  59 |     | 
           private static final long serialVersionUID = -26426318682076660L;  | 
  |  60 |     | 
             | 
  |  61 |     | 
           @XmlElement(name = Elements.STYLE_ID, required = false)  | 
  |  62 |     | 
           private final Long styleId;  | 
  |  63 |     | 
             | 
  |  64 |     | 
           @XmlElement(name = Elements.NAME, required = true)  | 
  |  65 |     | 
       private final String name;  | 
  |  66 |     | 
             | 
  |  67 |     | 
           @XmlElement(name = Elements.XML_CONTENT, required = false)  | 
  |  68 |     | 
       private final String xmlContent;  | 
  |  69 |     | 
             | 
  |  70 |     | 
           @XmlElement(name = Elements.ACTIVE, required = true)  | 
  |  71 |     | 
       private final boolean active;  | 
  |  72 |     | 
         | 
  |  73 |     | 
           @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)  | 
  |  74 |     | 
       private final Long versionNumber;  | 
  |  75 |     | 
             | 
  |  76 |     | 
           @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)  | 
  |  77 |     | 
           private final String objectId;  | 
  |  78 |     | 
     | 
  |  79 |    0 |        @SuppressWarnings("unused") | 
  |  80 |     | 
       @XmlAnyElement  | 
  |  81 |     | 
       private final Collection<Element> _futureElements = null;  | 
  |  82 |     | 
             | 
  |  83 |     | 
         | 
  |  84 |     | 
     | 
  |  85 |     | 
     | 
  |  86 |    0 |        private Style() { | 
  |  87 |    0 |                this.styleId = null;  | 
  |  88 |    0 |                this.name = null;  | 
  |  89 |    0 |                this.xmlContent = null;  | 
  |  90 |    0 |                this.active = false;  | 
  |  91 |    0 |                this.versionNumber = null;  | 
  |  92 |    0 |                this.objectId = null;  | 
  |  93 |    0 |        }  | 
  |  94 |     | 
         | 
  |  95 |    0 |        private Style(Builder builder) { | 
  |  96 |    0 |                this.styleId = builder.getStyleId();  | 
  |  97 |    0 |                this.name = builder.getName();  | 
  |  98 |    0 |                this.xmlContent = builder.getXmlContent();  | 
  |  99 |    0 |                this.active = builder.isActive();  | 
  |  100 |    0 |                this.versionNumber = builder.getVersionNumber();  | 
  |  101 |    0 |                this.objectId = builder.getObjectId();  | 
  |  102 |    0 |        }  | 
  |  103 |     | 
     | 
  |  104 |     | 
       @Override  | 
  |  105 |     | 
       public Long getStyleId() { | 
  |  106 |    0 |                    return this.styleId;  | 
  |  107 |     | 
           }  | 
  |  108 |     | 
     | 
  |  109 |     | 
       @Override  | 
  |  110 |     | 
       public String getName() { | 
  |  111 |    0 |                    return this.name;  | 
  |  112 |     | 
           }  | 
  |  113 |     | 
     | 
  |  114 |     | 
       @Override  | 
  |  115 |     | 
       public String getXmlContent() { | 
  |  116 |    0 |                    return this.xmlContent;  | 
  |  117 |     | 
           }  | 
  |  118 |     | 
             | 
  |  119 |     | 
       @Override  | 
  |  120 |     | 
       public boolean isActive() { | 
  |  121 |    0 |                    return this.active;  | 
  |  122 |     | 
           }  | 
  |  123 |     | 
             | 
  |  124 |     | 
           @Override  | 
  |  125 |     | 
           public Long getVersionNumber() { | 
  |  126 |    0 |                    return this.versionNumber;  | 
  |  127 |     | 
           }  | 
  |  128 |     | 
             | 
  |  129 |     | 
           @Override  | 
  |  130 |     | 
           public String getObjectId() { | 
  |  131 |    0 |                    return this.objectId;  | 
  |  132 |     | 
           }  | 
  |  133 |     | 
     | 
  |  134 |     | 
             | 
  |  135 |     | 
     | 
  |  136 |     | 
     | 
  |  137 |     | 
     | 
  |  138 |     | 
     | 
  |  139 |     | 
     | 
  |  140 |     | 
     | 
  |  141 |    0 |            public static final class Builder implements StyleContract, ModelBuilder, Serializable  { | 
  |  142 |     | 
                 | 
  |  143 |     | 
               private static final long serialVersionUID = -219369603932108436L;  | 
  |  144 |     | 
                 | 
  |  145 |     | 
                   private Long styleId;  | 
  |  146 |     | 
           private String name;  | 
  |  147 |     | 
           private String xmlContent;  | 
  |  148 |     | 
           private boolean active;  | 
  |  149 |     | 
           private Long versionNumber;  | 
  |  150 |     | 
           private String objectId;  | 
  |  151 |     | 
             | 
  |  152 |    0 |            private Builder(String name) { | 
  |  153 |    0 |                    setName(name);  | 
  |  154 |    0 |                    setActive(true);  | 
  |  155 |    0 |            }  | 
  |  156 |     | 
             | 
  |  157 |     | 
             | 
  |  158 |     | 
     | 
  |  159 |     | 
     | 
  |  160 |     | 
     | 
  |  161 |     | 
     | 
  |  162 |     | 
     | 
  |  163 |     | 
     | 
  |  164 |     | 
     | 
  |  165 |     | 
     | 
  |  166 |     | 
     | 
  |  167 |     | 
     | 
  |  168 |     | 
     | 
  |  169 |     | 
           public static Builder create(String name) { | 
  |  170 |    0 |                    return new Builder(name);  | 
  |  171 |     | 
           }  | 
  |  172 |     | 
             | 
  |  173 |     | 
             | 
  |  174 |     | 
     | 
  |  175 |     | 
     | 
  |  176 |     | 
     | 
  |  177 |     | 
     | 
  |  178 |     | 
     | 
  |  179 |     | 
     | 
  |  180 |     | 
     | 
  |  181 |     | 
     | 
  |  182 |     | 
     | 
  |  183 |     | 
     | 
  |  184 |     | 
           public static Builder create(StyleContract contract) { | 
  |  185 |    0 |                    if (contract == null) { | 
  |  186 |    0 |                            throw new IllegalArgumentException("contract was null"); | 
  |  187 |     | 
                   }  | 
  |  188 |    0 |                    Builder builder = create(contract.getName());  | 
  |  189 |    0 |                    builder.setStyleId(contract.getStyleId());  | 
  |  190 |    0 |                    builder.setXmlContent(contract.getXmlContent());  | 
  |  191 |    0 |                    builder.setActive(contract.isActive());  | 
  |  192 |    0 |                    builder.setVersionNumber(contract.getVersionNumber());  | 
  |  193 |    0 |                    builder.setObjectId(contract.getObjectId());  | 
  |  194 |    0 |                    return builder;  | 
  |  195 |     | 
           }  | 
  |  196 |     | 
             | 
  |  197 |     | 
           @Override  | 
  |  198 |     | 
           public Style build() { | 
  |  199 |    0 |                    return new Style(this);  | 
  |  200 |     | 
           }  | 
  |  201 |     | 
     | 
  |  202 |     | 
           @Override  | 
  |  203 |     | 
                   public Long getStyleId() { | 
  |  204 |    0 |                            return this.styleId;  | 
  |  205 |     | 
                   }  | 
  |  206 |     | 
     | 
  |  207 |     | 
             | 
  |  208 |     | 
     | 
  |  209 |     | 
     | 
  |  210 |     | 
     | 
  |  211 |     | 
     | 
  |  212 |     | 
                   public void setStyleId(Long styleId) { | 
  |  213 |    0 |                            this.styleId = styleId;  | 
  |  214 |    0 |                    }  | 
  |  215 |     | 
     | 
  |  216 |     | 
                   @Override  | 
  |  217 |     | 
                   public String getName() { | 
  |  218 |    0 |                            return this.name;  | 
  |  219 |     | 
                   }  | 
  |  220 |     | 
     | 
  |  221 |     | 
                     | 
  |  222 |     | 
     | 
  |  223 |     | 
     | 
  |  224 |     | 
     | 
  |  225 |     | 
     | 
  |  226 |     | 
     | 
  |  227 |     | 
     | 
  |  228 |     | 
     | 
  |  229 |     | 
     | 
  |  230 |     | 
                   public void setName(String name) { | 
  |  231 |    0 |                            if (StringUtils.isBlank(name)) { | 
  |  232 |    0 |                                    throw new IllegalArgumentException("name is blank"); | 
  |  233 |     | 
                           }  | 
  |  234 |    0 |                            this.name = name;  | 
  |  235 |    0 |                    }  | 
  |  236 |     | 
     | 
  |  237 |     | 
                   @Override  | 
  |  238 |     | 
                   public String getXmlContent() { | 
  |  239 |    0 |                            return this.xmlContent;  | 
  |  240 |     | 
                   }  | 
  |  241 |     | 
     | 
  |  242 |     | 
                     | 
  |  243 |     | 
     | 
  |  244 |     | 
     | 
  |  245 |     | 
     | 
  |  246 |     | 
     | 
  |  247 |     | 
     | 
  |  248 |     | 
                   public void setXmlContent(String xmlContent) { | 
  |  249 |    0 |                            this.xmlContent = xmlContent;  | 
  |  250 |    0 |                    }  | 
  |  251 |     | 
     | 
  |  252 |     | 
                   @Override  | 
  |  253 |     | 
                   public boolean isActive() { | 
  |  254 |    0 |                            return this.active;  | 
  |  255 |     | 
                   }  | 
  |  256 |     | 
     | 
  |  257 |     | 
                     | 
  |  258 |     | 
     | 
  |  259 |     | 
     | 
  |  260 |     | 
     | 
  |  261 |     | 
     | 
  |  262 |     | 
     | 
  |  263 |     | 
                   public void setActive(boolean active) { | 
  |  264 |    0 |                            this.active = active;  | 
  |  265 |    0 |                    }  | 
  |  266 |     | 
     | 
  |  267 |     | 
                   @Override  | 
  |  268 |     | 
                   public Long getVersionNumber() { | 
  |  269 |    0 |                            return this.versionNumber;  | 
  |  270 |     | 
                   }  | 
  |  271 |     | 
     | 
  |  272 |     | 
                     | 
  |  273 |     | 
     | 
  |  274 |     | 
     | 
  |  275 |     | 
     | 
  |  276 |     | 
     | 
  |  277 |     | 
     | 
  |  278 |     | 
     | 
  |  279 |     | 
     | 
  |  280 |     | 
     | 
  |  281 |     | 
     | 
  |  282 |     | 
                   public void setVersionNumber(Long versionNumber) { | 
  |  283 |    0 |                            this.versionNumber = versionNumber;  | 
  |  284 |    0 |                    }  | 
  |  285 |     | 
     | 
  |  286 |     | 
                   @Override  | 
  |  287 |     | 
                   public String getObjectId() { | 
  |  288 |    0 |                            return objectId;  | 
  |  289 |     | 
                   }  | 
  |  290 |     | 
                     | 
  |  291 |     | 
                     | 
  |  292 |     | 
     | 
  |  293 |     | 
     | 
  |  294 |     | 
     | 
  |  295 |     | 
     | 
  |  296 |     | 
     | 
  |  297 |     | 
     | 
  |  298 |     | 
     | 
  |  299 |     | 
     | 
  |  300 |     | 
     | 
  |  301 |     | 
                   public void setObjectId(String objectId) { | 
  |  302 |    0 |                            this.objectId = objectId;  | 
  |  303 |    0 |                    }  | 
  |  304 |     | 
                 | 
  |  305 |     | 
       }  | 
  |  306 |     | 
         | 
  |  307 |     | 
       @Override  | 
  |  308 |     | 
       public int hashCode() { | 
  |  309 |    0 |            return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE);  | 
  |  310 |     | 
       }  | 
  |  311 |     | 
     | 
  |  312 |     | 
       @Override  | 
  |  313 |     | 
       public boolean equals(Object obj) { | 
  |  314 |    0 |            return EqualsBuilder.reflectionEquals(obj, this, Constants.HASH_CODE_EQUALS_EXCLUDE);  | 
  |  315 |     | 
       }  | 
  |  316 |     | 
     | 
  |  317 |     | 
       @Override  | 
  |  318 |     | 
       public String toString() { | 
  |  319 |    0 |            return ToStringBuilder.reflectionToString(this);  | 
  |  320 |     | 
       }  | 
  |  321 |     | 
     | 
  |  322 |     | 
         | 
  |  323 |     | 
     | 
  |  324 |     | 
     | 
  |  325 |    0 |        static class Constants { | 
  |  326 |     | 
           final static String ROOT_ELEMENT_NAME = "style";  | 
  |  327 |     | 
           final static String TYPE_NAME = "StyleType";  | 
  |  328 |    0 |            final static String[] HASH_CODE_EQUALS_EXCLUDE = {CoreConstants.CommonElements.FUTURE_ELEMENTS}; | 
  |  329 |     | 
       }  | 
  |  330 |     | 
     | 
  |  331 |     | 
         | 
  |  332 |     | 
     | 
  |  333 |     | 
     | 
  |  334 |     | 
     | 
  |  335 |    0 |        static class Elements { | 
  |  336 |     | 
           final static String STYLE_ID = "styleId";  | 
  |  337 |     | 
           final static String NAME = "name";  | 
  |  338 |     | 
           final static String XML_CONTENT = "xmlContent";  | 
  |  339 |     | 
           final static String ACTIVE = "active";  | 
  |  340 |     | 
       }  | 
  |  341 |     | 
     | 
  |  342 |     | 
   }  |