View Javadoc

1   package org.kuali.ole.myaccount.renewal.bo;
2   
3   
4   import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
5   import org.kuali.rice.core.api.mo.ModelBuilder;
6   import javax.xml.bind.annotation.*;
7   import java.io.Serializable;
8   import java.util.ArrayList;
9   import java.util.List;
10  import org.apache.commons.collections.CollectionUtils;
11  
12  
13  
14  @XmlRootElement(name = OlePatronLoanDocuments.Constants.ROOT_ELEMENT_NAME)
15  @XmlAccessorType(XmlAccessType.NONE)
16  @XmlType(name = "PatronLoan", propOrder = {
17          OlePatronLoanDocuments.Elements.OLE_PATRON_LOAN_ITM
18  })
19  public class OlePatronLoanDocuments extends AbstractDataTransferObject implements  OlePatronLoanDocumentsContract{
20  
21      private static final long serialVersionUID = 1L;
22  
23      @XmlElement(name = Elements.OLE_PATRON_LOAN_ITM, required = false)
24      private final List<OlePatronLoanDocument> olePatronLoanItem;
25  
26  
27  
28      public OlePatronLoanDocuments(){
29          this.olePatronLoanItem=null;
30      }
31  
32      public  OlePatronLoanDocuments(Builder builder){
33  
34           this.olePatronLoanItem = new ArrayList<OlePatronLoanDocument>();
35          if (!CollectionUtils.isEmpty(builder.getOlePatronLoanDocuments())) {
36              for (OlePatronLoanDocument.Builder olePatronLoanDocument : builder.getOlePatronLoanDocuments()) {
37                  this.olePatronLoanItem.add(olePatronLoanDocument.build());
38              }
39          }
40      }
41  
42      /**
43       * This method converts the PersistableBusinessObjectBase OlePatronDocument into immutable object OlePatronDefinition
44       * @param bo
45       * @return OlePatronDefinition
46       */
47      public static OlePatronLoanDocument to(OleRenewalLoanDocument bo) {
48          if (bo == null) {
49              return null;
50          }
51          return OlePatronLoanDocument.Builder.create(bo).build();
52      }
53  
54  
55      @Override
56      public String getId() {
57          return null;
58      }
59  
60      @Override
61      public Long getVersionNumber() {
62          return null;
63      }
64  
65  
66      @Override
67      public List<? extends OlePatronLoanDocumentContract> getOlePatronLoanDocuments() {
68          return olePatronLoanItem;
69      }
70  
71      public static class Builder
72              implements Serializable, ModelBuilder, OlePatronLoanDocumentsContract
73      {
74          private List<OlePatronLoanDocument.Builder> olePatronLoanDocuments;
75          private Long versionNumber;
76          private String objectId;
77  
78          public void setVersionNumber(Long versionNumber) {
79              this.versionNumber = versionNumber;
80          }
81  
82          public String getObjectId() {
83              return objectId;
84          }
85  
86          public void setObjectId(String objectId) {
87              this.objectId = objectId;
88          }
89  
90          private Builder() { }
91  
92          public static Builder create() {
93              return new Builder();
94          }
95  
96          public static Builder create(OlePatronLoanDocumentsContract contract){
97  
98              if(contract == null) {
99                  throw new IllegalArgumentException("contract was null");
100             }
101             Builder builder = create();
102 
103             builder.olePatronLoanDocuments=new ArrayList<OlePatronLoanDocument.Builder>();
104             if (!CollectionUtils.isEmpty(contract.getOlePatronLoanDocuments())) {
105                 for (OlePatronLoanDocumentContract olePatronLoanDocumentContract : contract.getOlePatronLoanDocuments()) {
106                     builder.olePatronLoanDocuments.add(OlePatronLoanDocument.Builder.create(olePatronLoanDocumentContract));
107                 }
108             }
109 
110             builder.setVersionNumber(contract.getVersionNumber());
111 
112             //builder.setId(contract.getId());
113 
114             return builder;
115         }
116 
117 
118 
119         public OlePatronLoanDocuments build() {
120             return new OlePatronLoanDocuments(this);
121         }
122 
123         @Override
124         public String getId() {
125             return null;
126         }
127 
128         @Override
129         public Long getVersionNumber() {
130             return null;
131         }
132         @Override
133         public List<OlePatronLoanDocument.Builder> getOlePatronLoanDocuments() {
134             return olePatronLoanDocuments;
135         }
136 
137         public void setOlePatronLoanDocuments(List<OlePatronLoanDocumentContract> OlePatronLoanDocumentContract) {
138             this.olePatronLoanDocuments = olePatronLoanDocuments;
139         }
140 
141 
142 
143     }
144 
145 
146     static class Constants {
147 
148         final static String ROOT_ELEMENT_NAME = "olePatronLoanItems";
149     }
150 
151     static class Elements {
152         //final static String OLE_PATRON_LOAN_ITMS = "olePatronLoanItems";
153         final static String OLE_PATRON_LOAN_ITM = "olePatronLoanItem";
154 
155     }
156 
157 }