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.domain; 017 018import de.cuioss.test.generator.TypedGenerator; 019 020import static de.cuioss.test.generator.Generators.integers; 021 022/** 023 * Generates German postal codes (Postleitzahlen) for test data generation. 024 * 025 * <p>Characteristics:</p> 026 * <ul> 027 * <li>Generates 5-digit postal codes</li> 028 * <li>Range: 10000 - 99999</li> 029 * <li>Format matches official German postal code format</li> 030 * </ul> 031 * 032 * <p><em>Example usage:</em></p> 033 * <pre> 034 * var generator = new ZipCodeGenerator(); 035 * Integer zipCode = generator.next(); // e.g. 12345 036 * String formattedZip = String.format("%05d", zipCode); // Ensures 5 digits with leading zeros 037 * </pre> 038 * 039 * <p>Note: This generator returns {@link Integer} values. For display purposes, 040 * you may want to format the number to ensure it always shows 5 digits.</p> 041 * 042 * @author Oliver Wolff 043 */ 044public class ZipCodeGenerator implements TypedGenerator<Integer> { 045 046 private final TypedGenerator<Integer> zibCodes = integers(10000, 99999); 047 048 @Override 049 public Integer next() { 050 return zibCodes.next(); 051 } 052 053 @Override 054 public Class<Integer> getType() { 055 return Integer.class; 056 } 057}