Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2017-11-06 10:37:41 +0000
committerHenrik Rentz-Reichert2017-11-07 06:58:06 +0000
commit48d51b2b32f759e255f0cca154d2757c95d15e19 (patch)
treef1455e17e092e88c01feac4b6cf7f5ec2d2896ff /plugins/org.eclipse.etrice.core.common
parentb09856b29bfcaea08e9e57b14da3744c0a201867 (diff)
downloadorg.eclipse.etrice-48d51b2b32f759e255f0cca154d2757c95d15e19.tar.gz
org.eclipse.etrice-48d51b2b32f759e255f0cca154d2757c95d15e19.tar.xz
org.eclipse.etrice-48d51b2b32f759e255f0cca154d2757c95d15e19.zip
Bug 511330 - [core.genmodel.fsm] introduce simplified generator model
for state machines * manually merged newfsmgen to newfsmgen_finalize because no rebase was possible due to structural changes * rebased on master * switch to Oxygen and Xtend 2.12 Change-Id: If9a8c7421f07fb8e8fa824b7bc6761b9142b7eaf
Diffstat (limited to 'plugins/org.eclipse.etrice.core.common')
-rw-r--r--plugins/org.eclipse.etrice.core.common/xtend-gen/org/eclipse/etrice/core/common/validation/ValidationHelpers.java136
1 files changed, 136 insertions, 0 deletions
diff --git a/plugins/org.eclipse.etrice.core.common/xtend-gen/org/eclipse/etrice/core/common/validation/ValidationHelpers.java b/plugins/org.eclipse.etrice.core.common/xtend-gen/org/eclipse/etrice/core/common/validation/ValidationHelpers.java
new file mode 100644
index 000000000..7510e4031
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.common/xtend-gen/org/eclipse/etrice/core/common/validation/ValidationHelpers.java
@@ -0,0 +1,136 @@
+/**
+ * Copyright (c) 2014 protos software gmbh (http://www.protos.de).
+ * 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:
+ * hrentz (initial contribution)
+ */
+package org.eclipse.etrice.core.common.validation;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.function.Consumer;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.xtend.lib.Property;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.Pure;
+
+/**
+ * @author hrentz
+ */
+@SuppressWarnings("all")
+public class ValidationHelpers {
+ public static class NamedObject {
+ @Property
+ private String _name;
+
+ @Property
+ private EObject _obj;
+
+ @Property
+ private EStructuralFeature _feature;
+
+ public NamedObject(final String name, final EObject obj, final EStructuralFeature feature) {
+ this.setName(name);
+ this.setObj(obj);
+ this.setFeature(feature);
+ }
+
+ @Pure
+ public String getName() {
+ return this._name;
+ }
+
+ public void setName(final String name) {
+ this._name = name;
+ }
+
+ @Pure
+ public EObject getObj() {
+ return this._obj;
+ }
+
+ public void setObj(final EObject obj) {
+ this._obj = obj;
+ }
+
+ @Pure
+ public EStructuralFeature getFeature() {
+ return this._feature;
+ }
+
+ public void setFeature(final EStructuralFeature feature) {
+ this._feature = feature;
+ }
+ }
+
+ public static class NamedObjectList extends ArrayList<ValidationHelpers.NamedObject> {
+ public void addAll(final List<? extends EObject> items, final EStructuralFeature feature) {
+ final Consumer<EObject> _function = (EObject it) -> {
+ Object _eGet = it.eGet(feature);
+ ValidationHelpers.NamedObject _namedObject = new ValidationHelpers.NamedObject(((String) _eGet), it, feature);
+ this.add(_namedObject);
+ };
+ items.forEach(_function);
+ }
+ }
+
+ public static Iterable<ValidationHelpers.NamedObject> removeUniques(final List<ValidationHelpers.NamedObject> items) {
+ Iterable<ValidationHelpers.NamedObject> _xblockexpression = null;
+ {
+ final Set<String> allOfName = CollectionLiterals.<String>newHashSet();
+ final Set<String> duplicateNames = CollectionLiterals.<String>newHashSet();
+ for (final ValidationHelpers.NamedObject i : items) {
+ String _name = i.getName();
+ boolean _contains = allOfName.contains(_name);
+ if (_contains) {
+ String _name_1 = i.getName();
+ duplicateNames.add(_name_1);
+ } else {
+ String _name_2 = i.getName();
+ allOfName.add(_name_2);
+ }
+ }
+ final Function1<ValidationHelpers.NamedObject, Boolean> _function = (ValidationHelpers.NamedObject i_1) -> {
+ String _name_3 = i_1.getName();
+ return Boolean.valueOf(duplicateNames.contains(_name_3));
+ };
+ _xblockexpression = IterableExtensions.<ValidationHelpers.NamedObject>filter(items, _function);
+ }
+ return _xblockexpression;
+ }
+
+ public static Iterable<ValidationHelpers.NamedObject> inSameResource(final Iterable<ValidationHelpers.NamedObject> items, final Resource resource) {
+ final Function1<ValidationHelpers.NamedObject, Boolean> _function = (ValidationHelpers.NamedObject i) -> {
+ EObject _obj = i.getObj();
+ Resource _eResource = _obj.eResource();
+ return Boolean.valueOf(Objects.equal(_eResource, resource));
+ };
+ return IterableExtensions.<ValidationHelpers.NamedObject>filter(items, _function);
+ }
+
+ /**
+ * Visitor for inheritance, safeguards from null, eProxy and circular issues.
+ *
+ * @param start EObject, may be null
+ * @param function return null to exit
+ */
+ public static <E extends EObject> void saveRecursiveVisitor(final E start, final Function<E, E> function) {
+ final Set<E> visited = CollectionLiterals.<E>newHashSet();
+ E next = start;
+ while ((((!Objects.equal(next, null)) && (!next.eIsProxy())) && visited.add(next))) {
+ E _apply = function.apply(next);
+ next = _apply;
+ }
+ }
+}

Back to the top