blob: 5340fe3aba462a760166fd85a2344fb4b8114e25 [file] [log] [blame]
/**
* Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Pirchner - Initial implementation
*/
package org.eclipse.osbp.runtime.common.state.impl;
import java.util.Collection;
import org.eclipse.osbp.runtime.common.state.IDataState;
/**
* Combines the global data state and the dirty data state.
*/
public class DirtyDataAwareGlobalState implements IDataState {
private final IDataState dataState;
private final IDataState dirtyState;
public DirtyDataAwareGlobalState(IDataState dataState, IDataState dirtyState) {
this.dataState = dataState;
this.dirtyState = dirtyState;
}
@Override
public boolean contains(Object key) {
return dirtyState.contains(key) || dataState.contains(key);
}
@Override
public Object get(Object key) {
Object result = dirtyState.get(key);
if (result == null) {
result = dataState.get(key);
}
return result;
}
@Override
public void register(Object key, Object object) {
throw new UnsupportedOperationException("Not a valid call");
}
@Override
public void registerAll(Collection<Object> objects, Hashing hasher) {
throw new UnsupportedOperationException("Not a valid call");
}
@Override
public void invalidate(Object key) {
throw new UnsupportedOperationException("Not a valid call");
}
@Override
public long size() {
throw new UnsupportedOperationException("Not a valid call");
}
@Override
public boolean empty() {
throw new UnsupportedOperationException("Not a valid call");
}
}