001/*
002 * Copyright © 2018. Sir Wellington.
003 * Licensed under the Apache License, Version 2.0 (the "License");
004 * you may not use this file except in compliance with the License.
005 *
006 * You may obtain a copy of the License at
007 *     http://www.apache.org/licenses/LICENSE-2.0
008 *
009 * Unless required by applicable law or agreed to in writing, software
010 * distributed under the License is distributed on an "AS IS" BASIS,
011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 * See the License for the specific language governing permissions and
013 * limitations under the License.
014 */
015
016
017package tech.sirwellington.alchemy.test.junit.runners;
018
019import java.lang.annotation.Retention;
020import java.lang.annotation.Target;
021
022import tech.sirwellington.alchemy.annotations.access.Internal;
023import tech.sirwellington.alchemy.annotations.access.NonInstantiable;
024import tech.sirwellington.alchemy.generator.AlchemyGenerator;
025import tech.sirwellington.alchemy.generator.ObjectGenerators;
026
027import static java.lang.annotation.ElementType.FIELD;
028import static java.lang.annotation.RetentionPolicy.RUNTIME;
029import static tech.sirwellington.alchemy.test.Checks.Internal.checkNotNull;
030
031
032/**
033 * @author SirWellington
034 */
035@Target(FIELD)
036@Retention(RUNTIME)
037public @interface GeneratePojo
038{
039
040    @Internal
041    @NonInstantiable
042    static class Values
043    {
044        private Values() throws IllegalAccessException
045        {
046            throw new IllegalAccessException("cannot instantiate");
047        }
048
049        static <POJO> AlchemyGenerator<POJO> createGeneratorFor(GeneratePojo annotation, Class<POJO> classOfPojo)
050        {
051            checkNotNull(classOfPojo, "missing classOfPojo");
052            checkNotNull(annotation, "missing annotation");
053
054            return ObjectGenerators.pojos(classOfPojo);
055        }
056    }
057}