001/*
002 * Copyright 2023 the original author or authors.
003 * <p>
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 * <p>
008 * https://www.apache.org/licenses/LICENSE-2.0
009 * <p>
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.valueobjects.objects;
017
018/**
019 * Simple interface used for dynamically creating builder objects.
020 *
021 * @author Oliver Wolff
022 * @param <T> identifying the type of object to be instantiated by the builder
023 */
024public interface BuilderInstantiator<T> {
025
026    /**
027     * @return a newly created builder.
028     * @throws AssertionError in case the object could not be created
029     */
030    Object newBuilderInstance();
031
032    /**
033     * @return the class of the object that will be created by the contained
034     *         builder.
035     */
036    Class<T> getTargetClass();
037
038    /**
039     * @return the class of the builder.
040     */
041    Class<?> getBuilderClass();
042
043    /**
044     * Actually builds the target object
045     *
046     * @param builder
047     * @return the Object created by the contained builder
048     */
049    T build(Object builder);
050
051}