Coverage Report - org.kuali.rice.core.api.mo.common.active.InactivatableFromToUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
InactivatableFromToUtils
0%
0/7
0%
0/10
2.667
 
 1  
 /*
 2  
  * Copyright 2006-2011 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  
 
 17  
 package org.kuali.rice.core.api.mo.common.active;
 18  
 
 19  
 import java.sql.Timestamp;
 20  
 
 21  
 public final class InactivatableFromToUtils {
 22  
 
 23  0
     private InactivatableFromToUtils() {
 24  0
         throw new UnsupportedOperationException("do not call");
 25  
     }
 26  
 
 27  
     public static boolean isActive(Timestamp activeFromDate, Timestamp activeToDate, Timestamp activeAsOfDate) {
 28  0
         long asOfDate = System.currentTimeMillis();
 29  0
         if (activeAsOfDate != null) {
 30  0
             asOfDate = activeAsOfDate.getTime();
 31  
         }
 32  
 
 33  0
         return computeActive(activeFromDate, activeToDate, asOfDate);
 34  
     }
 35  
 
 36  
     private static boolean computeActive(Timestamp activeFromDate, Timestamp activeToDate, long asOfDate) {
 37  0
         return (activeFromDate == null || asOfDate >= activeFromDate.getTime()) &&
 38  
                 (activeToDate == null || asOfDate < activeToDate.getTime());
 39  
     }
 40  
 }