class WaterSubsystem extends BaseSubsystem<WaterSubsystemModel> {

	@Override
	protected void setAttribute(String name, Object value,
			SubsystemContext<WaterSubsystemModel> context)
			throws ErrorEventException {
		String address = (String) value;
		if(WaterSubsystemCapability.ATTR_PRIMARYWATERHEATER.equals(name)) {
			Model model = context.models().getModelByAddress(Address.fromString(address));
			if(model == null || !model.supports(WaterHeaterCapability.NAMESPACE)) {
				throw new ErrorEventException(WaterSubsystemErrors.notWaterHeater(address));
			}
	    }else if(WaterSubsystemCapability.ATTR_PRIMARYWATERSOFTENER.equals(name)) {
	    	Model model = context.models().getModelByAddress(Address.fromString(address));
			if(model == null || !model.supports(WaterSoftenerCapability.NAMESPACE)) {
				throw new ErrorEventException(WaterSubsystemErrors.notWaterSoftener(address));
			}
	    }
		super.setAttribute(name, value, context);
	}

}