/*
 * Copyright 2015 JBoss Inc
 *
 * Licensed 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.optaplanner.core.api.domain.valuerange;

import java.math.BigDecimal;

import org.optaplanner.core.impl.domain.valuerange.buildin.bigdecimal.BigDecimalValueRange;
import org.optaplanner.core.impl.domain.valuerange.buildin.primdouble.DoubleValueRange;
import org.optaplanner.core.impl.domain.valuerange.buildin.primint.IntValueRange;
import org.optaplanner.core.impl.domain.valuerange.buildin.primlong.LongValueRange;

/**
 * Factory for {@link ValueRange}.
 */
public class ValueRangeFactory {

    /**
     * Build a {@link CountableValueRange} of all {@code int} values between 2 bounds.
     * @param from inclusive minimum
     * @param to exclusive maximum, {@code >= from}
     * @return never null
     */
    public static CountableValueRange<Integer> createIntValueRange(int from, int to) {
        return new IntValueRange(from, to);
    }

    /**
     * Build a {@link CountableValueRange} of a subset of {@code int} values between 2 bounds.
     * @param from inclusive minimum
     * @param to exclusive maximum, {@code >= from}
     * @param incrementUnit {@code > 0}
     * @return never null
     */
    public static CountableValueRange<Integer> createIntValueRange(int from, int to, int incrementUnit) {
        return new IntValueRange(from, to, incrementUnit);
    }

    /**
     * Build a {@link CountableValueRange} of all {@code long} values between 2 bounds.
     * @param from inclusive minimum
     * @param to exclusive maximum, {@code >= from}
     * @return never null
     */
    public static CountableValueRange<Long> createLongValueRange(long from, long to) {
        return new LongValueRange(from, to);
    }

    /**
     * Build a {@link CountableValueRange} of a subset of {@code long} values between 2 bounds.
     * @param from inclusive minimum
     * @param to exclusive maximum, {@code >= from}
     * @param incrementUnit {@code > 0}
     * @return never null
     */
    public static CountableValueRange<Long> createLongValueRange(long from, long to, long incrementUnit) {
        return new LongValueRange(from, to, incrementUnit);
    }

    /**
     * Build a {@link CountableValueRange} of all {@link BigDecimal} values (of a specific scale) between 2 bounds.
     * All parameters must have the same {@link BigDecimal#scale()}.
     * @param from inclusive minimum
     * @param to exclusive maximum, {@code >= from}
     */
    public static CountableValueRange<BigDecimal> createBigDecimalValueRange(BigDecimal from, BigDecimal to) {
        return new BigDecimalValueRange(from, to);
    }

    /**
     * Build a {@link CountableValueRange} of a subset of {@code BigDecimal} values (of a specific scale) between 2 bounds.
     * All parameters must have the same {@link BigDecimal#scale()}.
     * @param from inclusive minimum
     * @param to exclusive maximum, {@code >= from}
     * @param incrementUnit {@code > 0}
     */
    public static CountableValueRange<BigDecimal> createBigDecimalValueRange(BigDecimal from, BigDecimal to, BigDecimal incrementUnit) {
        return new BigDecimalValueRange(from, to, incrementUnit);
    }

    /**
     * Build an uncountable {@link ValueRange} of all {@code double} values between 2 bounds.
     * @param from inclusive minimum
     * @param to exclusive maximum, {@code >= from}
     */
    public static ValueRange<Double> createDoubleValueRange(double from, double to) {
        return new DoubleValueRange(from, to);
    }

}

@@ -2714,177 +2714,86 @@
 ld a
- %7B@link CountableValueRange%7D of all %7B@link BigDecimal%7D values (of a specific scale) between 2 bounds.%0A     * All parameters must have the same %7B@link BigDecimal#scale()%7D
+n uncountable %7B@link ValueRange%7D of all %7B@code double%7D values between 2 bounds
 .%0A  
@@ -2901,33 +2901,24 @@
 blic static 
-Countable
 ValueRange%3CB
@@ -2920,74 +2920,58 @@
 nge%3C
-BigDecimal%3E createBigDecimalValueRange(BigDecimal from, BigDecimal
+Double%3E createDoubleValueRange(double from, double
  to)
@@ -2988,34 +2988,30 @@
  return new 
-BigDecimal
+Double
 ValueRange(f
@@ -3082,33 +3082,25 @@
 ge%7D of a
- subset of %7B@code
+ll %7B@link
  BigDeci
@@ -3114,30 +3114,8 @@
 lues
- (of a specific scale)
  bet
@@ -3291,48 +3291,8 @@
 om%7D%0A
-     * @param incrementUnit %7B@code %3E 0%7D%0A
     
@@ -3406,34 +3406,8 @@
 l to
-, BigDecimal incrementUnit
 ) %7B%0A
@@ -3450,39 +3450,24 @@
 nge(from, to
-, incrementUnit
 );%0A    %7D%0A%0A  
@@ -3490,86 +3490,185 @@
 ld a
-n uncountable %7B@link ValueRange%7D of all %7B@code double%7D values between 2 bounds
+ %7B@link CountableValueRange%7D of a subset of %7B@link BigDecimal%7D values (of a specific scale) between 2 bounds.%0A     * All parameters must have the same %7B@link BigDecimal#scale()%7D
 .%0A  
@@ -3746,32 +3746,72 @@
 %7B@code %3E= from%7D%0A
+     * @param incrementUnit %7B@code %3E 0%7D%0A
      */%0A    publ
@@ -3812,32 +3812,41 @@
   public static 
+Countable
 ValueRange%3CDoubl
@@ -3844,61 +3844,103 @@
 nge%3C
-Double%3E createDoubleValueRange(double from, double to
+BigDecimal%3E createBigDecimalValueRange(BigDecimal from, BigDecimal to, BigDecimal incrementUnit
 ) %7B%0A
@@ -3950,38 +3950,42 @@
      return new 
-Double
+BigDecimal
 ValueRange(from,
@@ -3979,28 +3979,43 @@
 ueRange(from, to
+, incrementUnit
 );%0A    %7D%0A%0A%7D%0A

Refactor (rearrange methods in ValueRangeFactory according to docs)