public class LightMultiplexor extends java.lang.Object implements SwitchableLight
LightMultiplexor
adapts a second SwitchableLight
by adding reference
counting to SwitchableLight.enableLight(boolean)
: the light will be lit if the net
number of enables is greater than zero.Modifier and Type | Field and Description |
---|---|
protected int |
enableCount |
protected static java.util.Set<LightMultiplexor> |
extantMultiplexors |
protected SwitchableLight |
target |
Modifier | Constructor and Description |
---|---|
protected |
LightMultiplexor(SwitchableLight target) |
Modifier and Type | Method and Description |
---|---|
void |
enableLight(boolean enable)
Turns the light on or off.
|
static LightMultiplexor |
forLight(SwitchableLight target) |
boolean |
isLightOn()
Answers whether the light is on or off
|
protected static final java.util.Set<LightMultiplexor> extantMultiplexors
protected final SwitchableLight target
protected int enableCount
protected LightMultiplexor(SwitchableLight target)
public static LightMultiplexor forLight(SwitchableLight target)
public boolean isLightOn()
Light
public void enableLight(boolean enable)
SwitchableLight
enableLight
in interface SwitchableLight
enable
- if true, the light turns on; otherwise the light turns off