View Javadoc
1   /**
2    * Copyright 2004-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.student.contract.model.test.source;
17  
18  import java.io.Serializable;
19  
20  import javax.xml.bind.annotation.XmlElement;
21  import javax.xml.bind.annotation.XmlTransient;
22  
23  import org.kuali.student.contract.model.test.source.HasAttributesAndMeta;
24  import org.kuali.student.contract.model.test.source.Meta;
25  
26  @SuppressWarnings("serial")
27  @XmlTransient
28  public abstract class HasAttributesAndMetaInfo extends HasAttributesInfo implements HasAttributesAndMeta, Serializable {
29  
30      @XmlElement
31      private final MetaInfo meta;
32  
33      protected HasAttributesAndMetaInfo() {
34          meta = null;
35      }
36  
37      protected HasAttributesAndMetaInfo(HasAttributesAndMeta builder) {
38          super(builder);
39          this.meta= null != builder.getMeta() ? new MetaInfo.Builder(builder.getMeta()).build() : null;
40      }
41  
42      @Override
43      public MetaInfo getMeta() {
44          return meta;
45      }
46  
47      public static class Builder extends HasAttributesInfo.Builder implements HasAttributesAndMeta {
48  
49          private MetaInfo meta;
50  
51          public Builder() {}
52  
53          public Builder(HasAttributesAndMeta hasAMInfo) {
54              super(hasAMInfo);
55              
56              if (null != hasAMInfo.getMeta()) {
57  	            MetaInfo.Builder builder = new MetaInfo.Builder();
58  	            builder.setCreateId(hasAMInfo.getMeta().getCreateId());
59  	            builder.setCreateTime(hasAMInfo.getMeta().getCreateTime());
60  	            builder.setUpdateId(hasAMInfo.getMeta().getUpdateId());
61  	            builder.setUpdateTime(hasAMInfo.getMeta().getUpdateTime());
62  	            builder.setVersionInd(hasAMInfo.getMeta().getVersionInd());
63  	            this.meta = builder.build();
64              }
65          }
66  
67          @Override
68          public MetaInfo getMeta() {
69              return meta;
70          }
71  
72          public void setMetaInfo(MetaInfo meta) {
73              this.meta = meta;
74          }
75      }
76  }