blob: ad1b458b9f644ea69b5d7111dbd593af95e2e40e [file] [log] [blame]
/**
********************************************************************************
* Copyright (c) 2020 Eclipse APP4MC contributors.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************
*/
package org.eclipse.app4mc.amalthea._import.btf.model;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.app4mc.amalthea.model.ProcessEventType;
import org.eclipse.app4mc.amalthea.model.RunnableEventType;
import org.eclipse.emf.common.util.Enumerator;
public enum BTFEntityType {
processsss(ProcessEventType.class, "T", "I"),
runnabless(RunnableEventType.class, "R");
private static final Map<String, BTFEntityType> name2Literal = Stream.of(values()).collect(Collectors.toMap(et -> et.entityTypeName, et -> et));
private final List<String> traceAliases;
private final String entityTypeName;
private BTFEntityType(Class<? extends Enumerator> eventTypeEnum, final String... traceAlias) {
this.traceAliases = Arrays.asList(traceAlias);
String entityTypeName = eventTypeEnum.getSimpleName();
entityTypeName = entityTypeName.substring(0, entityTypeName.indexOf("EventType")).toLowerCase();
this.entityTypeName = entityTypeName;
}
public String getName() {
return this.entityTypeName;
}
public String getUCName() {
final String lcName = this.getName();
final String ucName = lcName.substring(0, 1).toUpperCase() + lcName.substring(1);
return ucName;
}
public boolean isTraceAlias(final String traceAlias) {
return this.traceAliases.stream().anyMatch(traceAlias::equals);
}
public String getTraceAliases() {
return this.traceAliases.stream().map(ta -> "'" + ta + "'").collect(Collectors.joining(", "));
}
public static BTFEntityType getForName(String name) {
return name2Literal.get(name);
}
}