blob: 97e3154f0618e39d110175b0f35e0647ed7be492 [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2016 - 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 v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*/
package org.eclipse.osbp.utils.entitymock;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public abstract class ABaseMockResource extends ABaseMockObject {
protected Set<String> mockDataRows;
protected List<String> mockAttributes;
public ABaseMockResource() {
mockDataRows = new HashSet<String>();
mockAttributes = new ArrayList<String>();
mockData = new HashMap<String, Object>();
}
public void setAttributes(String... attributes) {
mockAttributes.clear();
for (String attribute : attributes) {
mockAttributes.add(attribute);
}
}
public void addDataRow(String key, String... datarow) {
mockDataRows.add(key);
for (int i=0; i<mockAttributes.size(); i++) {
if (i<datarow.length) {
mockData.put(key+"."+mockAttributes.get(i), datarow[i]);
}
else {
mockData.put(key+"."+mockAttributes.get(i), "");
}
}
}
public Set<String> getDataRows() {
return new HashSet<>(mockDataRows);
}
public Set<String> getAttributes() {
return new HashSet<>(mockAttributes);
}
public final Object getAttribute(String dataRow, String attribute) {
return mockData.get(dataRow+"."+attribute);
}
protected void generateDataRow() {
}
}