/*
 * Copyright 2010-2013 Ning, Inc.
 *
 * Ning licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package org.killbill.billing.catalog.api;

/**
 * The {@code BillingPeriod} supported in the system
 */
public enum BillingPeriod {
    MONTHLY(1),
    QUARTERLY(3),
    BIANNUAL(6),
    ANNUAL(12),
    BIENNIAL(24),
    NO_BILLING_PERIOD(0);

    private final int numberOfMonths;

    BillingPeriod(final int numberOfMonths) {
        this.numberOfMonths = numberOfMonths;
    }

    public int getNumberOfMonths() {
        return numberOfMonths;
    }
}

@@ -17,17 +17,17 @@
 2010-201
-3
+4
  Ning, I
@@ -36,16 +36,115 @@
 .%0A *
-%0A * Ning
+ Copyright 2014-2016 Groupon, Inc%0A * Copyright 2014-2016 The Billing Project, LLC%0A *%0A * The Billing Project
  lic
@@ -759,16 +759,46 @@
 g.api;%0A%0A
+import org.joda.time.Period;%0A%0A
 /**%0A * T
@@ -882,72 +882,252 @@
 d %7B%0A
-    MONTHLY(1),%0A    QUARTERLY(3),%0A    BIANNUAL(6),%0A    ANNUAL(12
+%0A    DAILY(Period.days(1)),%0A    WEEKLY(Period.weeks(1)),%0A    BIWEEKLY(Period.weeks(2)),%0A    THIRTY_DAYS(Period.days(30)),%0A    MONTHLY(Period.months(1)),%0A    QUARTERLY(Period.months(3)),%0A    BIANNUAL(Period.months(6)),%0A    ANNUAL(Period.years(1)
 ),%0A 
@@ -1142,10 +1142,23 @@
 IAL(
-24
+Period.years(2)
 ),%0A 
@@ -1178,17 +1178,27 @@
 _PERIOD(
-0
+Period.ZERO
 );%0A%0A    
@@ -1211,34 +1211,29 @@
 e final 
-int numberOfMonths
+Period period
 ;%0A%0A    B
@@ -1255,115 +1255,89 @@
 nal 
-int numberOfMonths) %7B%0A        this.numberOfMonths = numberOfMonths;%0A    %7D%0A%0A    public int getNumberOfMonths
+Period period) %7B%0A        this.period = period;%0A    %7D%0A%0A    public Period getPeriod
 () %7B
@@ -1356,22 +1356,14 @@
 urn 
-numberOfMonths
+period
 ;%0A  

change BillingPeriod to rely on org.joda.time.Period