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; 019 020import static de.cuioss.test.generator.Generators.integers; 021 022/** 023 * Generates {@link Number} instances using integer values. 024 * This generator provides a basic implementation that creates 025 * integer numbers within the full range of possible values. 026 * 027 * <p>Features:</p> 028 * <ul> 029 * <li>Uses {@link de.cuioss.test.generator.Generators#integers()} internally</li> 030 * <li>Generates values across the full integer range</li> 031 * <li>Thread-safe implementation</li> 032 * <li>Suitable for general numeric testing</li> 033 * </ul> 034 * 035 * <p><em>Example usage:</em></p> 036 * <pre> 037 * {@code 038 * // Create a generator 039 * var generator = new NumberGenerator(); 040 * 041 * // Generate single values 042 * Number value = generator.next(); 043 * 044 * // Generate collections 045 * var collectionGen = new CollectionGenerator<>(generator); 046 * List<Number> numbers = collectionGen.list(5); // List of 5 numbers 047 * } 048 * </pre> 049 * 050 * <p>This generator is particularly useful for testing:</p> 051 * <ul> 052 * <li>Generic number handling</li> 053 * <li>Numeric type conversions</li> 054 * <li>Mathematical operations</li> 055 * </ul> 056 * 057 * @author Oliver Wolff 058 * @see Number 059 * @see de.cuioss.test.generator.Generators#integers() 060 */ 061public class NumberGenerator implements TypedGenerator<Number> { 062 063 @Override 064 public Number next() { 065 return integers().next(); 066 } 067 068 @Override 069 public Class<Number> getType() { 070 return Number.class; 071 } 072 073}