1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.criteria.impl

File DurationFactory.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart6.png
69% of files have more coverage

Code metrics

0
9
10
1
134
47
10
1.11
0.9
10
1

Classes

Class Line # Actions
DurationFactory 25 9 0% 10 9
0.526315852.6%
 

Contributing tests

This file is covered by 5 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.criteria.impl;
21   
22    /**
23    * Helper factory class for creating Duration objects in velocity.
24    */
 
25    public class DurationFactory
26    {
27    /**
28    * A duration of exactly one day.
29    */
30    public static final Duration DAY = createDuration(0, 0, 0, 1);
31   
32    /**
33    * A duration of exactly one week.
34    */
35    public static final Duration WEEK = createDuration(0, 0, 1, 0);
36   
37    /**
38    * A duration of exactly one month
39    */
40    public static final Duration MONTH = createDuration(0, 1, 0, 0);
41   
42    /**
43    * A duration of exactly one year.
44    */
45    public static final Duration YEAR = createDuration(1, 0, 0, 0);
46   
 
47  0 toggle public DurationFactory()
48    {
49    }
50   
51    /**
52    * @see Duration#Duration(int, int, int, int)
53    */
 
54  20 toggle public static Duration createDuration(int years, int months, int weeks, int days)
55    {
56  20 return new Duration(years, months, weeks, days);
57    }
58   
59    /**
60    * Creates a new Duration instance having just the specified number of days. All the other fields are 0.
61    *
62    * @param days The number of days
63    * @return A new Duration instance
64    */
 
65  3 toggle public static Duration createDays(int days)
66    {
67  3 return createDuration(0, 0, 0, days);
68    }
69   
70    /**
71    * Creates a new Duration instance having just the specified number of weeks. All the other fields are 0.
72    *
73    * @param weeks The number of weeks
74    * @return A new Duration instance
75    */
 
76  3 toggle public static Duration createWeeks(int weeks)
77    {
78  3 return createDuration(0, 0, weeks, 0);
79    }
80   
81    /**
82    * Creates a new Duration instance having just the specified number of months. All the other fields are 0.
83    *
84    * @param months The number of months
85    * @return A new Duration instance
86    */
 
87  3 toggle public static Duration createMonths(int months)
88    {
89  3 return createDuration(0, months, 0, 0);
90    }
91   
92    /**
93    * Creates a new Duration instance having just the specified number of years. All the other fields are 0.
94    *
95    * @param years The number of years
96    * @return A new Duration instance
97    */
 
98  3 toggle public static Duration createYears(int years)
99    {
100  3 return createDuration(years, 0, 0, 0);
101    }
102   
103    /**
104    * Helper method for accessing {@link #DAY} static field in velocity.
105    */
 
106  0 toggle public static Duration getDAY()
107    {
108  0 return DAY;
109    }
110   
111    /**
112    * Helper method for accessing {@link #WEEK} static field in velocity.
113    */
 
114  0 toggle public static Duration getWEEK()
115    {
116  0 return WEEK;
117    }
118   
119    /**
120    * Helper method for accessing {@link #MONTH} static field in velocity.
121    */
 
122  0 toggle public static Duration getMONTH()
123    {
124  0 return MONTH;
125    }
126   
127    /**
128    * Helper method for accessing {@link #YEAR} static field in velocity.
129    */
 
130  0 toggle public static Duration getYEAR()
131    {
132  0 return YEAR;
133    }
134    }