@Override public void removeDataObserver(Observer<M> observer) { dataObserver.removeObserver(observer); } }
/** * {@inheritDoc} * * @return {@inheritDoc} */ @Override public BuilderSyncSetup<MB> getBuilderSetup() { return new BuilderSyncSetup<>(dataBuilder, dataBuilderReadLock, dataBuilderWriteLock, this); }
@Override public void addDataObserver(Observer<M> observer) { dataObserver.addObserver(observer); }
/** * {@inheritDoc} * * @param unitTemplateId {@inheritDoc} * @return {@inheritDoc} * @throws CouldNotPerformException {@inheritDoc} */ @Override public UnitTemplate getUnitTemplateById(final String unitTemplateId) throws CouldNotPerformException { return unitTemplateRegistry.get(unitTemplateId).getMessage(); }
protected Set<String> getRemovedUnitIds() { Set<String> removedUnitIds = new HashSet<>(); hostedUnitDiff.getRemovedMessageMap().getMessages().forEach((removedUnitConfig) -> { removedUnitIds.add(removedUnitConfig.getId()); }); return removedUnitIds; }
protected Set<AbstractUnitController> getNewUnitController() { Set<AbstractUnitController> newUnitController = new HashSet<>(); hostedUnitDiff.getNewMessageMap().getMessages().forEach((newUnitConfig) -> { newUnitController.add(unitMap.get(newUnitConfig.getId())); }); return newUnitController; }
public AbstractHostUnitController(final Class unitClass, final DB builder) throws InstantiationException { super(unitClass, builder); this.unitMap = new HashMap<>(); this.hostedUnitDiff = new ProtobufListDiff<>(); }
/** * Reset the unit registry observer by removing it reseting the unit diff and adding the observer again. * This is needed in unit tests because if multiple tests are run and in theses tests * the MockRegistry is restarted then the observer is registered on an old instance of the unit remote * and thus the effects of the observer cannot be tested. * * @throws InterruptedException thrown if Registries.getUnitRegistry is interrupted * @throws org.openbase.jul.exception.CouldNotPerformException thrown if the unit registry is not available */ private static void resetUnitRegistryObserver() throws InterruptedException, CouldNotPerformException { Registries.getUnitRegistry().removeDataObserver(UNIT_REGISTRY_OBSERVER); UNIT_DIFF.replaceOriginMap(new IdentifiableMessageMap<>(Registries.getUnitRegistry().getDalUnitConfigs())); Registries.getUnitRegistry().addDataObserver(UNIT_REGISTRY_OBSERVER); }
/** * {@inheritDoc} * * @param consumer {@inheritDoc} * @return {@inheritDoc} */ @Override public ClosableDataBuilder<MB> getDataBuilder(final Object consumer, final boolean notifyChange) { return new ClosableDataBuilder<>(getBuilderSetup(), consumer, notifyChange); }
@Override public void processData(String id, IdentifiableMessage<String, UnitConfig, UnitConfig.Builder> entry, ProtoBufMessageMap<String, UnitConfig, UnitConfig.Builder> entryMap, ProtoBufRegistry<String, UnitConfig, UnitConfig.Builder> registry) throws CouldNotPerformException, EntryModification { // rootLocation is saved to only make this check once per consistency process if (rootLocation == null) { // method validates if there is only one root location an if not tries to compute a valid one rootLocation = LocationUtils.detectRootLocation(entry.getMessage(), entryMap, this); } }
@Override public void removeServiceStateObserver(final ServiceTempus serviceTempus, final ServiceType serviceType, final Observer observer) { serviceTempusServiceTypeObservableMap.get(serviceTempus).get(serviceType).removeObserver(observer); }
@Override public void addServiceStateObserver(ServiceTempus serviceTempus, ServiceType serviceType, Observer observer) { serviceTempusServiceTypeObservableMap.get(serviceTempus).get(serviceType).addObserver(observer); }
/** * {@inheritDoc} * * @param consumer {@inheritDoc} * @return {@inheritDoc} */ @Override public ClosableDataBuilder<MB> getDataBuilder(final Object consumer) { return new ClosableDataBuilder<>(getBuilderSetup(), consumer); }
@Override public void processData(String id, IdentifiableMessage<String, UnitConfig, UnitConfig.Builder> entry, ProtoBufMessageMap<String, UnitConfig, UnitConfig.Builder> entryMap, ProtoBufRegistry<String, UnitConfig, UnitConfig.Builder> registry) throws CouldNotPerformException, EntryModification { loopTestBottomUp(entry.getMessage(), registry); }
@Override public void removeServiceStateObserver(ServiceTempus serviceTempus, ServiceType serviceType, Observer observer) { serviceTempusServiceTypeObservableMap.get(serviceTempus).get(serviceType).removeObserver(observer); }
@Override public void addServiceStateObserver(final ServiceTempus serviceTempus, final ServiceType serviceType, final Observer observer) { serviceTempusServiceTypeObservableMap.get(serviceTempus).get(serviceType).addObserver(observer); }
/** * {@inheritDoc} * * @param deviceClassId {@inheritDoc} * @return {@inheritDoc} * @throws CouldNotPerformException {@inheritDoc} */ @Override public DeviceClass getDeviceClassById(String deviceClassId) throws CouldNotPerformException { return deviceClassRegistry.get(deviceClassId).getMessage(); }
/** * {@inheritDoc} * * @param groupConfigId * @return * @throws CouldNotPerformException */ @Override public UnitConfig getUnitGroupConfigById(final String groupConfigId) throws CouldNotPerformException { return unitGroupUnitConfigRegistry.get(groupConfigId).getMessage(); }
@Override public UnitConfig getAppConfigById(String appUnitConfigId) throws CouldNotPerformException { unitRegistryRemote.validateData(); return appUnitConfigRemoteRegistry.get(appUnitConfigId).getMessage(); }
@Override public UnitConfig getUnitGroupConfigById(final String groupConfigId) throws CouldNotPerformException { validateData(); return unitGroupUnitConfigRemoteRegistry.get(groupConfigId).getMessage(); }