Coverage Report - org.kuali.student.core.academiccalendar.dto.KeyDateInfo
 
Classes in this File Line Coverage Branch Coverage Complexity
KeyDateInfo
0%
0/15
0%
0/4
1.286
KeyDateInfo$Builder
0%
0/18
0%
0/4
1.286
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.core.academiccalendar.dto;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.Date;
 20  
 import java.util.List;
 21  
 import org.w3c.dom.Element;
 22  
 
 23  
 import javax.xml.bind.annotation.XmlAccessType;
 24  
 import javax.xml.bind.annotation.XmlAccessorType;
 25  
 import javax.xml.bind.annotation.XmlAnyElement;
 26  
 import javax.xml.bind.annotation.XmlAttribute;
 27  
 import javax.xml.bind.annotation.XmlElement;
 28  
 import javax.xml.bind.annotation.XmlType;
 29  
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 30  
 
 31  
 import org.kuali.student.common.infc.ModelBuilder;
 32  
 import org.kuali.student.r2.common.dto.KeyEntityInfo;
 33  
 import org.kuali.student.core.academiccalendar.infc.KeyDate;
 34  
 
 35  
 import org.kuali.student.core.ws.binding.JaxbAttributeMapListAdapter;
 36  
 
 37  
 
 38  
 /**
 39  
  * Information about a key date.
 40  
  *
 41  
  * @Author tom
 42  
  * @Since Tue Apr 05 14:22:34 EDT 2011
 43  
  */ 
 44  
 
 45  
 @XmlAccessorType(XmlAccessType.FIELD)
 46  
 @XmlType(name = "KeyDateInfo", propOrder = {"key", "typeKey", "stateKey", "name", "descr", "isDateRange", "startDate", "endDate", "metaInfo", "attributes", "_futureElements"})
 47  
 
 48  
 public class KeyDateInfo extends KeyEntityInfo implements KeyDate, Serializable {
 49  
 
 50  
     private static final long serialVersionUID = 1L;
 51  
 
 52  
     @XmlElement
 53  
     private final Boolean isDateRange;
 54  
 
 55  
     @XmlElement
 56  
     private final Date startDate;
 57  
 
 58  
     @XmlElement
 59  
     private final Date endDate;
 60  
 
 61  
     @XmlAnyElement
 62  
     private final List<Element> _futureElements;  
 63  
 
 64  0
     private KeyDateInfo() {
 65  0
         isDateRange = false;
 66  0
         startDate = null;
 67  0
         endDate = null;
 68  0
         _futureElements = null;
 69  0
     }
 70  
 
 71  
     /**
 72  
      * Constructs a new KeyDateInfo from another KeyDate.
 73  
      *
 74  
      * @param keyDate the KeyDate to copy
 75  
      */
 76  
     public KeyDateInfo(KeyDate keyDate) {
 77  0
         super(keyDate);
 78  0
         this.isDateRange = keyDate.getIsDateRange();
 79  0
         this.startDate = null != keyDate.getStartDate() ? new Date(keyDate.getStartDate().getTime()) : null;
 80  0
         this.endDate = null != keyDate.getEndDate() ? new Date(keyDate.getEndDate().getTime()) : null;
 81  0
         _futureElements = null;
 82  0
     }
 83  
 
 84  
     /**
 85  
      * Tests if this keyDate has a date range. If true, the end date
 86  
      * value follows the start date.
 87  
      *
 88  
      * @return true if this KeyDate has different start end end
 89  
      *         dates, false if this KeyDate represents a single date
 90  
      */
 91  
     @Override
 92  
     public Boolean getIsDateRange() {
 93  0
         return isDateRange;
 94  
     }
 95  
 
 96  
     /**
 97  
      * Gets the start Date and time of the keyDate.
 98  
      *
 99  
      * @return the keyDate start
 100  
      */
 101  
     @Override
 102  
     public Date getStartDate() {
 103  0
         return startDate;
 104  
     }
 105  
 
 106  
     /**
 107  
      * Gets the end Date and time of the keyDate.
 108  
      *
 109  
      * @return the keyDate end
 110  
      */
 111  
     @Override
 112  
     public Date getEndDate() {
 113  0
         return endDate;
 114  
     }
 115  
 
 116  
     /**
 117  
      * The builder class for this KeyDateInfo.
 118  
      */
 119  0
     public static class Builder extends KeyEntityInfo.Builder implements ModelBuilder<KeyDateInfo>, KeyDate {
 120  
 
 121  
         private Boolean isDateRange;
 122  
         private Date startDate;
 123  
         private Date endDate;
 124  
 
 125  
         /**
 126  
          * Constructs a new builder.
 127  
          */
 128  0
         public Builder() {
 129  0
         }
 130  
 
 131  
         /**
 132  
          *  Constructs a new builder initialized from another
 133  
          *  KeyDate.
 134  
          */
 135  
         public Builder(KeyDate keyDate) {
 136  0
             super(keyDate);
 137  0
             this.isDateRange = keyDate.getIsDateRange();
 138  0
             this.startDate = null != keyDate.getStartDate() ? new Date(keyDate.getStartDate().getTime()) : null;
 139  0
             this.endDate = null != keyDate.getEndDate() ? new Date(keyDate.getEndDate().getTime()) : null;
 140  0
         }
 141  
 
 142  
         /**
 143  
          * Builds the KeyDate.
 144  
          *
 145  
          * @return a new KeyDate
 146  
          */
 147  
         public KeyDateInfo build() {
 148  0
             return new KeyDateInfo(this);
 149  
         }
 150  
 
 151  
         /**
 152  
          * Tests if this keyDate has a date range. If true, the end date
 153  
          * value follows the start date.
 154  
          *
 155  
          * @return true if this KeyDate has different start end end
 156  
          *         dates, false if this KeyDate represents a single date
 157  
          */
 158  
         @Override
 159  
         public Boolean getIsDateRange() {
 160  0
             return isDateRange;
 161  
         }
 162  
 
 163  
         /**
 164  
          * Sets the date range flag.
 165  
          *
 166  
          * @param isDateRange true if this KeyDate has different
 167  
          *         start end end dates, false if this KeyDate
 168  
          *         represents a single date
 169  
          */
 170  
         public void dateRange(Boolean isDateRange) {
 171  0
             this.isDateRange = isDateRange;
 172  0
         }
 173  
 
 174  
         /**
 175  
          * Gets the start date.
 176  
          *
 177  
          * @return the KeyDate start date
 178  
          */
 179  
         @Override
 180  
         public Date getStartDate() {
 181  0
             return startDate;
 182  
         }
 183  
 
 184  
         /**
 185  
          * Sets the KeyDate start date.
 186  
          *
 187  
          * @param endDate the start date
 188  
          */
 189  
         public void setStartDate(Date startDate) {
 190  0
             this.startDate = new Date(startDate.getTime());
 191  0
         }
 192  
 
 193  
         /**
 194  
          * Gets the start date.
 195  
          *
 196  
          * @return the KeyDate end date
 197  
          */
 198  
         @Override
 199  
         public Date getEndDate() {
 200  0
             return endDate;
 201  
         }
 202  
 
 203  
         /**
 204  
          * Sets the KeyDate end date.
 205  
          *
 206  
          * @param endDate the end date
 207  
          */
 208  
         public void setEndDate(Date endDate) {
 209  0
             this.endDate = new Date(endDate.getTime());
 210  0
         }
 211  
     }
 212  
 }