/** * {@inheritDoc} * * @throws org.openbase.jul.exception.NotAvailableException */ @Override public UnitTemplate getUnitTemplate() throws NotAvailableException { if (template == null) { throw new NotAvailableException("UnitTemplate"); } return template; }
/** * Method returns the latest triggered value. * * @return the latest value. * @throws NotAvailableException is thrown if a value was never triggered. */ public VALUE getLatestValue() throws NotAvailableException { if (latestValue == null) { throw new NotAvailableException("LatestValue"); } return latestValue; }
/** * Method returns the timestamp of the Stopwatch start. * * @return the timestamp in milliseconds. * @throws org.openbase.jul.exception.NotAvailableException is thrown in case the Stopwatch was never started. */ public long getStartTime() throws NotAvailableException { if (startTime == -1) { throw new NotAvailableException("StartTime"); } return startTime; }
private Package detectVersionConverterPackage() throws CouldNotPerformException { Package converterPackage; try { converterPackage = Class.forName((getClass().getPackage().getName() + "." + DB_CONVERTER_PACKAGE_NAME + ".ConverterPackageIdentifier")).getPackage(); } catch (ClassNotFoundException ex) { throw new NotAvailableException("ConverterPackage[" + getClass().getPackage().getName() + "." + DB_CONVERTER_PACKAGE_NAME + ".ConverterPackageIdentifier" + "]", ex); } return converterPackage; }
protected RSBSynchronizedRemoteServer(final Scope scope, final Double timeout) throws InstantiationException { super(scope, null); try { if (timeout == null) { throw new NotAvailableException("timeout"); } this.timeout = timeout; } catch (CouldNotPerformException ex) { throw new InstantiationException(this, ex); } }
private Scope detectScope(final CONFIG config) throws NotAvailableException { try { return (Scope) getConfigField(FIELD_SCOPE, config); } catch (CouldNotPerformException ex) { throw new NotAvailableException("scope"); } }
protected RSBSynchronizedParticipant(final Scope scope, final ParticipantConfig config) throws InstantiationException { try { if (scope == null) { throw new NotAvailableException("scope"); } this.scope = scope; this.config = config; } catch (CouldNotPerformException ex) { throw new InstantiationException(this, ex); } }
public boolean checkIfReachable() { try { return InetAddress.getByName(hostName).isReachable(REACHABLE_TIMEOUT); } catch (IOException ex) { ExceptionPrinter.printHistory(new NotAvailableException(hostName + " is not reachable!", ex), logger); return false; } }
@Override public TemperatureState getTemperatureState() throws NotAvailableException { try { return getData().getTemperatureState(); } catch (CouldNotPerformException ex) { throw new NotAvailableException("TemperatureState", ex); } }
@Override public StandbyState getStandbyState() throws NotAvailableException { try { return getData().getStandbyState(); } catch (CouldNotPerformException ex) { throw new NotAvailableException("StandbyState", ex); } }
@Override public TemperatureState getTemperatureState() throws NotAvailableException { try { return getData().getTemperatureState(); } catch (CouldNotPerformException ex) { throw new NotAvailableException("TemperatureState", ex); } }
@Override public TemperatureState getTargetTemperatureState() throws NotAvailableException { try { return getData().getTargetTemperatureState(); } catch (CouldNotPerformException ex) { throw new NotAvailableException("TargetTemperatureState", ex); } } }
@Override public UserPresenceState getUserPresenceState() throws NotAvailableException { try { return getData().getUserPresenceState(); } catch (CouldNotPerformException ex) { throw new NotAvailableException("user presence state", ex); } }
@Override public AlarmState getSmokeAlarmState() throws NotAvailableException { try { return getData().getSmokeAlarmState(); } catch (CouldNotPerformException ex) { throw new NotAvailableException("SmokeAlarmState", ex); } }
@Override public SmokeState getSmokeState() throws NotAvailableException { try { return getData().getSmokeState(); } catch (CouldNotPerformException ex) { throw new NotAvailableException("SmokeState", ex); } } }
private static UnitConfig getRootLocationUnitConfig(final Map<String, IdentifiableMessage<String, UnitConfig, UnitConfig.Builder>> locations) throws NotAvailableException { try { for (final IdentifiableMessage<String, UnitConfig, UnitConfig.Builder> locationUnitConfig : locations.values()) { if (isRootLocation(locationUnitConfig.getMessage(), locations)) { return locationUnitConfig.getMessage(); } } throw new InvalidStateException("Registry does not provide a root location!"); } catch (CouldNotPerformException ex) { throw new NotAvailableException("RootLocation", ex); } }
protected final Object getDataField(String name) throws CouldNotPerformException { try { Descriptors.FieldDescriptor findFieldByName = getData().getDescriptorForType().findFieldByName(name); if (findFieldByName == null) { throw new NotAvailableException("Field[" + name + "] does not exist for type " + getData().getClass().getName()); } return getData().getField(findFieldByName); } catch (Exception ex) { throw new CouldNotPerformException("Could not return value of field [" + name + "] for " + this, ex); } }
private String getRootLocationId() throws CouldNotPerformException { for (UnitConfig location : locationRegistry.getMessages()) { if (location.getLocationConfig().getRoot()) { return location.getId(); } } throw new NotAvailableException("rootLocation"); } }
public String getServiceIdByType(ServiceType serviceType) throws CouldNotPerformException { for (ServiceTemplate serviceTemplate : serviceTemplateRegistry.getMessages()) { if (serviceTemplate.getType() == serviceType) { return serviceTemplate.getId(); } } throw new NotAvailableException("Now service template for type[" + serviceType.name() + "] found!", "service id"); } }
@Override public void processData(final String id, final IdentifiableMessage<String, UnitConfig, UnitConfig.Builder> entry, final ProtoBufMessageMap<String, UnitConfig, UnitConfig.Builder> entryMap, final ProtoBufRegistry<String, UnitConfig, UnitConfig.Builder> registry) throws CouldNotPerformException, EntryModification { AgentConfig agentConfig = entry.getMessage().getAgentConfig(); if (!agentConfig.hasAgentClassId() || agentConfig.getAgentClassId().isEmpty()) { throw new NotAvailableException("agentclass.id"); } // get throws a CouldNotPerformException if the agent class with the id does not exists agentClassRegistry.get(agentConfig.getAgentClassId()); } }