Component state - Accessors for driver-related information

This commit is contained in:
Emmanuel BENOîT 2015-09-17 22:41:52 +02:00
parent 7cfb53c60e
commit 97eb6477d7

View file

@ -87,7 +87,7 @@ public final class ComponentState
this.component = component; this.component = component;
@SuppressWarnings( "unchecked" ) @SuppressWarnings( "unchecked" )
ThrowingFunction< Object , String > np = (ThrowingFunction< Object , String >) ci.getNameProvider( ); final ThrowingFunction< Object , String > np = (ThrowingFunction< Object , String >) ci.getNameProvider( );
String name; String name;
if ( np != null ) { if ( np != null ) {
try { try {
@ -203,6 +203,37 @@ public final class ComponentState
} }
/**
* @return the component for which this component is a driver, or <code>null</code> if this component is not another
* component's driver
*/
public ComponentState getMainComponent( )
{
return this.mainComponent;
}
/**
* @return an unmodifiable set listing this component's drivers
*/
public Set< ComponentState > getDrivers( )
{
return Collections.unmodifiableSet( this.drivers );
}
/**
* Adds the state records for the component's drivers to a collection
*
* @param output
* the collection to add the records to
*/
public void getDrivers( final Collection< ComponentState > output )
{
output.addAll( this.drivers );
}
/** /**
* @return <code>true</code> if the component was initialised, <code>false</code> if it wasn't (or if it was * @return <code>true</code> if the component was initialised, <code>false</code> if it wasn't (or if it was
* destroyed) * destroyed)
@ -437,7 +468,7 @@ public final class ComponentState
} catch ( final FunctionException e ) { } catch ( final FunctionException e ) {
throw e.getCause( ); throw e.getCause( );
} }
} catch ( Throwable t ) { } catch ( final Throwable t ) {
if ( t instanceof ComponentLifecycleException ) { if ( t instanceof ComponentLifecycleException ) {
throw (ComponentLifecycleException) t; throw (ComponentLifecycleException) t;
} }