001/*
002 * Copyright © 2025 CUI-OpenSource-Software (info@cuioss.de)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package de.cuioss.test.generator.impl;
017
018import de.cuioss.test.generator.TypedGenerator;
019import de.cuioss.test.generator.internal.net.java.quickcheck.generator.PrimitiveGenerators;
020import lombok.AllArgsConstructor;
021import lombok.NoArgsConstructor;
022
023/**
024 * Generates {@link Float} objects within a configurable range.
025 * 
026 * <p>Features:</p>
027 * <ul>
028 *   <li>Configurable range through constructor parameters</li>
029 *   <li>Default range: {@link Float#MIN_VALUE} to {@link Float#MAX_VALUE}</li>
030 *   <li>Thread-safe implementation</li>
031 *   <li>Uses double precision for internal generation to ensure even distribution</li>
032 * </ul>
033 * 
034 * <p><em>Example usage:</em></p>
035 * <pre>
036 * // Generate floats using full range
037 * var generator = new FloatObjectGenerator();
038 * Float value = generator.next();
039 * 
040 * // Generate floats within specific range
041 * var rangeGenerator = new FloatObjectGenerator(0.0f, 100.0f);
042 * Float bounded = rangeGenerator.next(); // Value between 0 and 100
043 * </pre>
044 * 
045 * @author Oliver Wolff
046 * @see PrimitiveGenerators
047 */
048@AllArgsConstructor
049@NoArgsConstructor
050public class FloatObjectGenerator implements TypedGenerator<Float> {
051
052    private float low = Float.MIN_VALUE;
053    private float high = Float.MAX_VALUE;
054
055    @Override
056    public Float next() {
057        return PrimitiveGenerators.doubles(low, high).next().floatValue();
058    }
059
060    @Override
061    public Class<Float> getType() {
062        return Float.class;
063    }
064
065}