You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.8 KiB
74 lines
1.8 KiB
8 years ago
|
/*******************************************************************************
|
||
|
* Copyright (c) 2015, 2017 IRT AESE (IRT Saint Exupery).
|
||
|
* 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:
|
||
|
* Bassem Ouni and Pierre Gaufillet (IRT Saint Exupéry) - initial API and implementation
|
||
|
*
|
||
|
*******************************************************************************/
|
||
|
package com.irtsaintexupery.capella2aadl.requests;
|
||
|
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Map;
|
||
|
import java.util.Set;
|
||
|
|
||
|
import org.polarsys.capella.core.data.capellamodeller.Project;
|
||
|
|
||
|
public class Bus {
|
||
|
private String name;
|
||
|
|
||
|
private String type;
|
||
|
|
||
|
private static Map<String, int[]> busCounters = null;
|
||
|
|
||
|
public static Set<String> getBusNames(Project project) {
|
||
|
return busCounters.keySet();
|
||
|
}
|
||
|
|
||
|
public static Bus createIncrementedNameFromCategory(String type) {
|
||
|
if(busCounters == null) {
|
||
|
init();
|
||
|
}
|
||
|
|
||
|
if (!busCounters.containsKey(type)) {
|
||
|
busCounters.put(type, new int[] { 1 });
|
||
|
} else {
|
||
|
busCounters.get(type)[0]++;
|
||
|
}
|
||
|
return new Bus(type + "_" + busCounters.get(type)[0], type);
|
||
|
}
|
||
|
|
||
|
private Bus(String aName) {
|
||
|
name = aName;
|
||
|
}
|
||
|
|
||
|
private Bus(String aName, String aType) {
|
||
|
name = aName;
|
||
|
type = aType;
|
||
|
}
|
||
|
|
||
|
public String getType() {
|
||
|
return type;
|
||
|
}
|
||
|
|
||
|
public void setType(String type) {
|
||
|
this.type = type;
|
||
|
}
|
||
|
|
||
|
public String getName() {
|
||
|
return name;
|
||
|
}
|
||
|
|
||
|
public void setName(String name) {
|
||
|
this.name = name;
|
||
|
}
|
||
|
|
||
|
public static void init() {
|
||
|
busCounters = new HashMap<String, int[]>();
|
||
|
}
|
||
|
|
||
|
}
|