| /** |
| * |
| * 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 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: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| */ |
| package org.eclipse.osbp.xtext.entitymock.common; |
| |
| import java.util.ArrayList; |
| import java.util.HashSet; |
| import java.util.List; |
| import java.util.Set; |
| |
| public abstract class ABaseMockResource extends ABaseMockObject { |
| |
| protected Set<String> mockDataRows = new HashSet<>(); |
| protected List<String> mockAttributes = new ArrayList<>(); |
| |
| 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) { |
| getMockData().put(key+"."+mockAttributes.get(i), datarow[i]); |
| } |
| else { |
| getMockData().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 getMockData().get(dataRow+"."+attribute); |
| } |
| |
| protected void generateDataRow() { |
| } |
| } |