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