001/*
002 * Copyright 2016 RedRoma, Inc..
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 */
016
017
018package tech.sirwellington.alchemy.test.junit.runners;
019
020
021import java.lang.annotation.Retention;
022import java.lang.annotation.Target;
023
024import tech.sirwellington.alchemy.annotations.access.Internal;
025import tech.sirwellington.alchemy.annotations.access.NonInstantiable;
026import tech.sirwellington.alchemy.generator.AlchemyGenerator;
027import tech.sirwellington.alchemy.generator.BooleanGenerators;
028
029import static java.lang.annotation.ElementType.FIELD;
030import static java.lang.annotation.RetentionPolicy.RUNTIME;
031import static tech.sirwellington.alchemy.test.Checks.Internal.checkNotNull;
032
033/**
034 * Used in with the {@link AlchemyTestRunner}, this Annotations allows the
035 * Runtime Injection of Generated Booleans from the {@link AlchemyGenerator} library.
036 * <p>
037 * Example:
038 * <pre>
039 * {@code
040 * `@RunWith(AlchemyTestRunner.class)
041 * public class ExampleTest
042 * {
043 *   `@GenerateBoolean
044 *   private Boolean openNow;
045 *
046 * }
047 * }
048 * </pre>
049 * <p>
050 * Note, '`' (ticks) used to escape Javadocs.
051 *
052 * @author SirWellington
053 * @see GenerateInteger
054 */
055@Target(FIELD)
056@Retention(RUNTIME)
057public @interface GenerateBoolean
058{
059
060    @Internal
061    @NonInstantiable
062    static class Values
063    {
064        private Values() throws IllegalAccessException
065        {
066            throw new IllegalAccessException("cannot instantiate");
067        }
068
069        static AlchemyGenerator<Boolean> createGeneratorFor(GenerateBoolean annotation)
070        {
071            checkNotNull(annotation, "annotation is null");
072            return BooleanGenerators.booleans();
073        }
074    }
075}