Package org.jboss.arquillian.drone.spi
Interface DronePointContext<DRONE>
-
public interface DronePointContext<DRONE>Context unique for eachDronePoint. It stores configuration, future instance and metadata.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceDronePointContext.MetadataKey<VALUE>Utility interface used for unique identification of metadata inDronePointContext.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <CONF extends DroneConfiguration<CONF>>
CONFgetConfigurationAs(Class<CONF> configurationClass)Returns an instance ofDroneConfigurationcast to desired type.DronePoint<DRONE>getDronePoint()Returns an instance ofDronePoint, which is this context bound to.DRONEgetInstance()Returns an instance of drone.<CAST_DRONE>
CAST_DRONEgetInstanceAs(Class<CAST_DRONE> droneClass)Returns an instance of drone, cast to desired type.<KEY extends DronePointContext.MetadataKey<VALUE>,VALUE>
VALUEgetMetadata(Class<KEY> keyClass)Returns saved metadata for the given key.booleanhasConfiguration()Returns true if configuration is set.booleanhasFutureInstance()Returns true if future instance (CachingCallable) is set.<KEY extends DronePointContext.MetadataKey<VALUE>,VALUE>
booleanhasMetadata(Class<KEY> keyClass)Returns true if there are metadata set for the given key.booleanisInstantiated()Returns true ifCachingCallable.isValueCached()is true.voidremoveConfiguration()Removes configuration.voidremoveFutureInstance()Removes future or instantiated drone instance, depending on the state.<KEY extends DronePointContext.MetadataKey<VALUE>,VALUE>
voidremoveMetadata(Class<KEY> keyClass)Removes metadata set for the given key.<CONF extends DroneConfiguration<CONF>>
voidsetConfiguration(CONF configuration)Sets theDroneConfiguration.voidsetFutureInstance(CachingCallable<DRONE> futureInstance)SetsCachingCallablefor future drone instantiation.<KEY extends DronePointContext.MetadataKey<VALUE>,VALUE>
voidsetMetadata(Class<KEY> keyClass, VALUE metadata)Sets given metadata under specified key.
-
-
-
Method Detail
-
getDronePoint
DronePoint<DRONE> getDronePoint()
Returns an instance ofDronePoint, which is this context bound to.
-
getInstance
DRONE getInstance() throws IllegalStateException
Returns an instance of drone. If the drone was not yet instantiated, it will fireBeforeDroneInstantiatedevent, then instantiate the drone and fireAfterDroneInstantiatedevent.- Throws:
IllegalStateException- if there is no future instance set.
-
getInstanceAs
<CAST_DRONE> CAST_DRONE getInstanceAs(Class<CAST_DRONE> droneClass) throws IllegalArgumentException, IllegalStateException
Returns an instance of drone, cast to desired type. If the drone was not yet instantiated, it will fireBeforeDroneInstantiatedevent, then instantiate the drone and fireAfterDroneInstantiatedevent.- Parameters:
droneClass- Class to cast drone instance to.- Throws:
IllegalArgumentException- If the given class is null.IllegalStateException- If there is no future instance set or if the instance cannot be cast to desired type. UseDronePoint.conformsTo(Class)to make sure the drone can be cast to it.
-
getConfigurationAs
<CONF extends DroneConfiguration<CONF>> CONF getConfigurationAs(Class<CONF> configurationClass) throws IllegalArgumentException, IllegalStateException
Returns an instance ofDroneConfigurationcast to desired type.- Throws:
IllegalStateException- If there is no configuration set or the configuration cannot be cast to the desired type.IllegalArgumentException- If the given configuration class is null.
-
getMetadata
<KEY extends DronePointContext.MetadataKey<VALUE>,VALUE> VALUE getMetadata(Class<KEY> keyClass) throws IllegalArgumentException
Returns saved metadata for the given key.- Throws:
IllegalArgumentException- If the given key class is null.
-
isInstantiated
boolean isInstantiated()
Returns true ifCachingCallable.isValueCached()is true.
-
hasFutureInstance
boolean hasFutureInstance()
Returns true if future instance (CachingCallable) is set.
-
hasConfiguration
boolean hasConfiguration()
Returns true if configuration is set.
-
hasMetadata
<KEY extends DronePointContext.MetadataKey<VALUE>,VALUE> boolean hasMetadata(Class<KEY> keyClass) throws IllegalArgumentException
Returns true if there are metadata set for the given key.- Throws:
IllegalArgumentException- If the given key class is null.
-
setFutureInstance
void setFutureInstance(CachingCallable<DRONE> futureInstance)
SetsCachingCallablefor future drone instantiation. Remember that the best practise is to instantiate drones lazily, at the very last moment.
-
setConfiguration
<CONF extends DroneConfiguration<CONF>> void setConfiguration(CONF configuration)
Sets theDroneConfiguration.
-
setMetadata
<KEY extends DronePointContext.MetadataKey<VALUE>,VALUE> void setMetadata(Class<KEY> keyClass, VALUE metadata) throws IllegalArgumentException
Sets given metadata under specified key. If there are metadata set for the given key, it will replace them.- Throws:
IllegalArgumentException- If the given key class is null.
-
removeFutureInstance
void removeFutureInstance()
Removes future or instantiated drone instance, depending on the state.
-
removeConfiguration
void removeConfiguration()
Removes configuration.
-
removeMetadata
<KEY extends DronePointContext.MetadataKey<VALUE>,VALUE> void removeMetadata(Class<KEY> keyClass)
Removes metadata set for the given key.- Throws:
IllegalArgumentException- If the given key class is null.
-
-