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; 020 021/** 022 * Generates {@link Short} objects across the full range of possible short values. 023 * 024 * <p>Features:</p> 025 * <ul> 026 * <li>Generates values from -32,768 to 32,767 ({@link Short#MIN_VALUE} to {@link Short#MAX_VALUE})</li> 027 * <li>Even distribution across the entire short range</li> 028 * <li>Thread-safe implementation</li> 029 * <li>Uses integer generation internally for precision</li> 030 * </ul> 031 * 032 * <p><em>Example usage:</em></p> 033 * <pre> 034 * var generator = new ShortObjectGenerator(); 035 * Short value = generator.next(); // Returns a random short value 036 * </pre> 037 * 038 * <p>This generator is particularly useful for testing:</p> 039 * <ul> 040 * <li>Boundary conditions at Short.MIN_VALUE and Short.MAX_VALUE</li> 041 * <li>Type conversion scenarios</li> 042 * <li>Numeric overflow cases</li> 043 * </ul> 044 * 045 * @author Oliver Wolff 046 * @see PrimitiveGenerators 047 */ 048public class ShortObjectGenerator implements TypedGenerator<Short> { 049 050 @Override 051 public Short next() { 052 return PrimitiveGenerators.integers(-32768, 32767).next().shortValue(); 053 } 054 055 @Override 056 public Class<Short> getType() { 057 return Short.class; 058 } 059 060}