public Entry entry(final Region r) { EList<Vertex> _vertices = r.getVertices(); final Function1<Vertex, Boolean> _function = new Function1<Vertex, Boolean>() { public Boolean apply(final Vertex v) { boolean _and = false; if (!(v instanceof Entry)) { _and = false; } else { boolean _or = false; boolean _or_1 = false; String _name = v.getName(); boolean _equals = Objects.equal(_name, null); if (_equals) { _or_1 = true; } else { String _name_1 = v.getName(); boolean _equals_1 = "".equals(_name_1); _or_1 = (_equals || _equals_1); } if (_or_1) { _or = true; } else { String _name_2 = v.getName(); boolean _equals_2 = Objects.equal(_name_2, "default"); _or = (_or_1 || _equals_2); } _and = ((v instanceof Entry) && _or); } return Boolean.valueOf(_and); } }; Vertex _findFirst = IterableExtensions.<Vertex>findFirst(_vertices, _function); return ((Entry) _findFirst); }
@Check(CheckType.FAST) public void transitionsWithNoTrigger(Transition trans) { if (trans.getSource() instanceof Entry || trans.getSource() instanceof Choice || trans.getSource() instanceof Synchronization) { return; } if (trans.getSource() instanceof org.yakindu.sct.model.sgraph.State) { org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) trans.getSource(); if (state.isComposite()) { for (Region r : state.getRegions()) { for (Vertex v : r.getVertices()) { if (v instanceof Exit) { return; } } } } } if (!STextValidationModelUtils.getExitPointSpecs(trans.getProperties()).isEmpty()) { return; } if (trans.getTrigger() == null) { warning(ISSUE_TRANSITION_WITHOUT_TRIGGER, trans, null, -1); } }
public static Entry _createEntry(EntryKind kind, String name, Region r) { Entry entry = SGraphFactory.eINSTANCE.createEntry(); if (kind != null) entry.setKind(kind); else entry.setKind(EntryKind.INITIAL); entry.setName(name); if (r != null) r.getVertices().add(entry); return entry; }
public List<RegularState> collectLeafStates( final Region region, final List<RegularState> leafStates) { EList<Vertex> _vertices = region.getVertices(); for (final Vertex v : _vertices) { if ((v instanceof RegularState)) { this.collectLeafStates(((RegularState) v), leafStates); } } return leafStates; }
private Exit createSemanticExitPoint(Transition transition) { Region exitPointContainer = getExitPointContainer(transition); String name = getExitPointName(transition); Exit exitPoint = null; Iterator<Vertex> iterator = exitPointContainer.getVertices().iterator(); while (iterator.hasNext()) { Vertex next = iterator.next(); if (next instanceof Exit) { Exit current = (Exit) next; if (name.equals(current.getName())) { // Do nothing, there already exists an entry point return current; } } } exitPoint = SGraphFactory.eINSTANCE.createExit(); exitPoint.setName(name); exitPointContainer.getVertices().add(exitPoint); return exitPoint; }
public boolean requireShallowHistory(final Region r) { EList<Vertex> _vertices = r.getVertices(); Iterable<Entry> _filter = Iterables.<Entry>filter(_vertices, Entry.class); final Function1<Entry, Boolean> _function = new Function1<Entry, Boolean>() { public Boolean apply(final Entry v) { EntryKind _kind = v.getKind(); boolean _equals = Objects.equal(_kind, EntryKind.SHALLOW_HISTORY); return Boolean.valueOf(_equals); } }; boolean _exists = IterableExtensions.<Entry>exists(_filter, _function); return _exists; }
protected Entry createSemanticEntryPoint(Transition transition) { Region entryPointTarget = getEntryPointContainer(transition); String name = getEntryPointName(transition); Entry entryPoint = null; Iterator<Vertex> iterator = entryPointTarget.getVertices().iterator(); while (iterator.hasNext()) { Vertex next = iterator.next(); if (next instanceof Entry) { Entry current = (Entry) next; if (name.equals(current.getName())) { // Do nothing, there already exists an entry point return current; } } } entryPoint = SGraphFactory.eINSTANCE.createEntry(); entryPoint.setName(name); entryPointTarget.getVertices().add(entryPoint); Transition entryPointTransition = SGraphFactory.eINSTANCE.createTransition(); entryPointTransition.setSource(entryPoint); entryPointTransition.setTarget(transition.getTarget()); return entryPoint; }
/** * Checks if all composite states that are siblings of a shallow history can enter their regions. * * @param e */ @Check(CheckType.FAST) public void regionCantBeEnteredUsingShallowHistory(Entry e) { if (e.getKind() == EntryKind.SHALLOW_HISTORY) { // get all regions off all sibling states List<Region> regions = new ArrayList<Region>(); for (Vertex v : e.getParentRegion().getVertices()) { if (v instanceof org.yakindu.sct.model.sgraph.State) { org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) v; regions.addAll(state.getRegions()); } } // check each region for (Region r : regions) { // first determine if the region contains a default entry Entry defaultEntry = null; for (Vertex v : r.getVertices()) { if (v instanceof Entry) { String name = v.getName().trim().toLowerCase(); if (name != null || "".equals(name) || "default".equals(name)) { defaultEntry = (Entry) v; break; } } } // now check error conditions if (defaultEntry == null) { error(ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY, r, null, -1); } else if (defaultEntry.getOutgoingTransitions().size() != 1) { error( ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY, r, null, -1); } } } }
public List<RegularState> collectLeafStates( final RegularState state, final List<RegularState> leafStates) { boolean _isLeaf = this.isLeaf(state); if (_isLeaf) { leafStates.add(state); } else { if ((state instanceof State)) { final State s = ((State) state); EList<Region> _regions = s.getRegions(); for (final Region r : _regions) { EList<Vertex> _vertices = r.getVertices(); for (final Vertex v : _vertices) { if ((v instanceof RegularState)) { this.collectLeafStates(((RegularState) v), leafStates); } } } } } return leafStates; }
public static FinalState _createFinalState(Region r) { FinalState state = SGraphFactory.eINSTANCE.createFinalState(); if (r != null) r.getVertices().add(state); return state; }
public static State _createState(String name, Region r) { State state = SGraphFactory.eINSTANCE.createState(); state.setName(name); if (r != null) r.getVertices().add(state); return state; }
public Iterable<Entry> collectEntries(final Region r) { EList<Vertex> _vertices = r.getVertices(); Iterable<Entry> _filter = Iterables.<Entry>filter(_vertices, Entry.class); return _filter; }