1 /* 2 * Entreri, an entity-component framework in Java 3 * 4 * Copyright (c) 2013, Michael Ludwig 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without modification, 8 * are permitted provided that the following conditions are met: 9 * 10 * Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 package com.lhkbob.entreri; 28 29 import java.lang.annotation.*; 30 31 /** 32 * <p/> 33 * The Requires annotation can be used to specify dependencies within a package of 34 * components. If one component requires the use of another, such as a scene or light 35 * component needing a transform, this can be a convenient way to specify this 36 * relationship and reduce the amount of explicit configuration during entity 37 * initialization. 38 * <p/> 39 * If a component type extends an additional abstract component type that also is 40 * annotated with Requires, the union of the required types is the effective set of 41 * types. 42 * <p/> 43 * When a component type that has been annotated with this annotation is added to an 44 * entity, all required component types that are not already attached to the entity are 45 * added. All newly added components have their owner set to the initial component so that 46 * when it's removed, the required components are cleaned up as well. 47 * 48 * @author Michael Ludwig 49 */ 50 @Documented 51 @Target(ElementType.TYPE) 52 @Retention(RetentionPolicy.RUNTIME) 53 public @interface Requires { 54 /** 55 * @return All Component types required by the annotated component type 56 */ 57 Class<? extends Component>[] value(); 58 }