View Javadoc

1   /*
2    * Copyright 2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 1.0 (the
5    * "License"); you may not use this file except in compliance with the
6    * License.  You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl1.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  import java.util.List;
20  
21  import javax.xml.bind.annotation.XmlAccessType;
22  import javax.xml.bind.annotation.XmlAccessorType;
23  import javax.xml.bind.annotation.XmlAnyElement;
24  import javax.xml.bind.annotation.XmlElement;
25  import javax.xml.bind.annotation.XmlType;
26  
27  import org.kuali.student.contract.model.test.source.Context;
28  import org.kuali.student.contract.model.test.source.ModelBuilder;
29  import org.w3c.dom.Element;
30  
31  /**
32   * @author Kamal
33   */
34  @XmlAccessorType(XmlAccessType.FIELD)
35  @XmlType(name = "ContextInfo", propOrder = {"principalId", "localeLanguage", "localeVariant", "localeRegion", "localeScript", "timeZone", "attributes", "_futureElements"})
36  public class ContextInfo extends HasAttributesInfo implements Context, Serializable {
37  
38      private static final long serialVersionUID = 1L;
39      @XmlElement
40      private final String principalId;
41      @XmlElement
42      private final String localeLanguage;
43      @XmlElement
44      private final String localeVariant;
45      @XmlElement
46      private final String localeRegion;
47      @XmlElement
48      private final String localeScript;
49      @XmlElement
50      private final String timeZone;
51      @XmlAnyElement
52      private final List<Element> _futureElements;
53  
54      private ContextInfo() {
55          principalId = null;
56          localeLanguage = null;
57          localeVariant = null;
58          localeRegion = null;
59          localeScript = null;
60          timeZone = null;
61          _futureElements = null;
62      }
63  
64      private ContextInfo(Context builder) {
65          super(builder);
66          this.principalId = builder.getPrincipalId();
67          this.localeLanguage = builder.getLocaleLanguage();
68          this.localeVariant = builder.getLocaleVariant();
69          this.localeRegion = builder.getLocaleRegion();
70          this.localeScript = builder.getLocaleScript();
71          this.timeZone = builder.getTimeZone();
72          this._futureElements = null;
73      }
74  
75      @Override
76      public String getPrincipalId() {
77          return principalId;
78      }
79  
80      @Override
81      public String getLocaleLanguage() {
82          return localeLanguage;
83      }
84  
85      @Override
86      public String getLocaleVariant() {
87          return localeVariant;
88      }
89  
90      @Override
91      public String getLocaleRegion() {
92          return localeRegion;
93      }
94  
95      @Override
96      public String getLocaleScript() {
97          return localeScript;
98      }
99  
100     @Override
101     public String getTimeZone() {
102         return timeZone;
103     }
104 
105     public static class Builder extends HasAttributesInfo.Builder implements ModelBuilder<ContextInfo>, Context {
106 
107         private String principalId;
108         private String localeLanguage;
109         private String localeVariant;
110         private String localeRegion;
111         private String localeScript;
112         private String timeZone;
113 
114         public Builder() {
115         }
116 
117         public Builder(Context ctxInfo) {
118             super(ctxInfo);
119             this.principalId = ctxInfo.getPrincipalId();
120             this.localeLanguage = ctxInfo.getLocaleLanguage();
121             this.localeVariant = ctxInfo.getLocaleVariant();
122             this.localeRegion = ctxInfo.getLocaleRegion();
123             this.localeScript = ctxInfo.getLocaleScript();
124             this.timeZone = ctxInfo.getTimeZone();
125         }
126 
127         public ContextInfo build() {
128             return new ContextInfo(this);
129         }
130 
131         @Override
132         public String getPrincipalId() {
133             return principalId;
134         }
135 
136         @Override
137         public String getLocaleLanguage() {
138             return localeLanguage;
139         }
140 
141         @Override
142         public String getLocaleVariant() {
143             return localeVariant;
144         }
145 
146         @Override
147         public String getLocaleRegion() {
148             return localeRegion;
149         }
150 
151         @Override
152         public String getLocaleScript() {
153             return localeScript;
154         }
155 
156         @Override
157         public String getTimeZone() {
158             return timeZone;
159         }
160 
161         public Builder principalId(String principalId) {
162             this.principalId = principalId;
163             return this;
164         }
165 
166         public Builder localeLanguage(String localeLanguage) {
167             this.localeLanguage = localeLanguage;
168             return this;
169         }
170 
171         public Builder localeRegion(String localeRegion) {
172             this.localeRegion = localeRegion;
173             return this;
174         }
175 
176         public Builder localeVariant(String localeVariant) {
177             this.localeVariant = localeVariant;
178             return this;
179         }
180 
181         public Builder localeScript(String localeScript) {
182             this.localeScript = localeScript;
183             return this;
184         }
185         
186         public Builder timeZone(String timeZone) {
187             this.timeZone = timeZone;
188             return this;
189         }
190     }
191 }