001 /*
002 * Copyright 2010 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may
003 * not use this file except in compliance with the License. You may obtain a copy of the License at
004 * http://www.osedu.org/licenses/ECL-2.0 Unless required by applicable law or agreed to in writing, software distributed
005 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
006 * implied. See the License for the specific language governing permissions and limitations under the License.
007 */
008 package org.kuali.student.common.dto;
009
010 import java.io.Serializable;
011
012 import javax.xml.bind.annotation.XmlElement;
013 import javax.xml.bind.annotation.XmlTransient;
014
015 import org.kuali.student.common.infc.HasAttributesAndMeta;
016 import org.kuali.student.common.infc.Meta;
017
018 @SuppressWarnings("serial")
019 @XmlTransient
020 public abstract class HasAttributesAndMetaInfo extends HasAttributesInfo implements HasAttributesAndMeta, Serializable {
021
022 @XmlElement
023 private final MetaInfo metaInfo;
024
025 protected HasAttributesAndMetaInfo() {
026 metaInfo = null;
027 }
028
029 protected HasAttributesAndMetaInfo(HasAttributesAndMeta builder) {
030 super(builder);
031 this.metaInfo = null != builder.getMetaInfo() ? new MetaInfo.Builder(builder.getMetaInfo()).build() : null;
032 }
033
034 @Override
035 public MetaInfo getMetaInfo() {
036 return metaInfo;
037 }
038
039 public static class Builder extends HasAttributesInfo.Builder implements HasAttributesAndMeta {
040
041 private Meta metaInfo;
042
043 public Builder() {}
044
045 public Builder(HasAttributesAndMeta hasAMInfo) {
046 super(hasAMInfo);
047
048 if (null != hasAMInfo.getMetaInfo()) {
049 MetaInfo.Builder builder = new MetaInfo.Builder();
050 builder.setCreateId(hasAMInfo.getMetaInfo().getCreateId());
051 builder.setCreateTime(hasAMInfo.getMetaInfo().getCreateTime());
052 builder.setUpdateId(hasAMInfo.getMetaInfo().getUpdateId());
053 builder.setUpdateTime(hasAMInfo.getMetaInfo().getUpdateTime());
054 builder.setVersionInd(hasAMInfo.getMetaInfo().getVersionInd());
055 this.metaInfo = builder.build();
056 }
057 }
058
059 @Override
060 public Meta getMetaInfo() {
061 return metaInfo;
062 }
063
064 public void setMetaInfo(Meta metaInfo) {
065 this.metaInfo = metaInfo;
066 }
067 }
068 }