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.Generators;
019import de.cuioss.test.generator.TypedGenerator;
020
021import java.time.LocalDateTime;
022
023/**
024 * Generates random {@link LocalDateTime} instances for testing purposes.
025 * The generator combines {@link java.time.LocalDate} and {@link java.time.LocalTime} values
026 * to create complete date-time instances.
027 *
028 * <p>Generation details:</p>
029 * <ul>
030 *   <li>Uses {@link Generators#localDates()} for the date component</li>
031 *   <li>Uses {@link Generators#localTimes()} for the time component</li>
032 *   <li>Generates valid combinations across the full range of possible values</li>
033 *   <li>Thread-safe implementation</li>
034 * </ul>
035 *
036 * <p><em>Example usage:</em></p>
037 * <pre>
038 * var generator = new LocalDateTimeGenerator();
039 * LocalDateTime dateTime = generator.next();
040 * // dateTime will be a random but valid LocalDateTime instance
041 * </pre>
042 *
043 * @author Eugen Fischer
044 * @see LocalDateGenerator
045 * @see LocalTimeGenerator
046 */
047public class LocalDateTimeGenerator implements TypedGenerator<LocalDateTime> {
048
049    @Override
050    public LocalDateTime next() {
051        return LocalDateTime.of(Generators.localDates().next(), Generators.localTimes().next());
052    }
053
054    @Override
055    public Class<LocalDateTime> getType() {
056        return LocalDateTime.class;
057    }
058
059}