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.internal.net.java.quickcheck;
017
018/**
019 * Declarative object generator definition.
020 * <p>
021 * User should call implementation of ObjectGenerator as follows:
022 * </p>
023 *
024 * <pre>{@code
025 * ObjectGenerator<T> g;
026 * Generator<R> methodGenerator;
027 * g.on(g.getRecorder().method()).returns(methodGenerator);
028 * }</pre>
029 *
030 * @param <T> type of object generated
031 */
032public interface ObjectGenerator<T> extends Generator<T> {
033
034    /**
035     * Implementation of T that is used to define the method a generator should be
036     * defined for.
037     *
038     * @return an implementation of T used only to record method calls
039     */
040    T getRecorder();
041
042    /**
043     * Define a method a generator should be defined for.
044     *
045     * @param <R>   type of the return type
046     * @param value is ignored
047     * @return {@link ReturnValue} instance to define a generator for this method
048     */
049    <R> ReturnValue<R> on(R value);
050
051    interface ReturnValue<R> {
052
053        void returns(Generator<? extends R> generator);
054    }
055}