/** * returns initial mode as true if it is a SOM without modes ("no Modes" aka NORMAL_SOM_NME) or if * all of the modes are initial mode */ @Override public final boolean isInitial() { if (isInitial == null) { Boolean value = Boolean.TRUE; final Iterator<ModeInstance> i = getCurrentModes().iterator(); // Is the list empty? if (!i.hasNext()) { // The SOM has no modes. Check to make sure, it is the only SOM, i.e., "No Modes". Otherwise // it is not initial if (((SystemInstance) eContainer()).getSystemOperationModes().size() != 1) { value = Boolean.FALSE; } } else { while (i.hasNext()) { final ModeInstance mi = i.next(); final Mode m = mi.getMode(); if (!m.isInitial()) { value = Boolean.FALSE; break; } } } isInitial = value; } return isInitial.booleanValue(); }
@Override public String toString() { /* * Don't return a string with spaces in it becase this is used to * create a name for the object, and we cannot have spaces in our * name, or else it messes up the XML/XMI processing. */ final StringBuffer name = new StringBuffer(); EList ml = getCurrentModes(); for (Iterator it = ml.iterator(); it.hasNext(); ) { final ModeInstance mi = (ModeInstance) it.next(); final ComponentInstance ci = (ComponentInstance) mi.eContainer(); name.append(ci.getComponentInstancePath()); if (name.length() > 0) { name.append("."); } name.append(mi.getName()); if (it.hasNext()) { name.append("#"); } } return name.toString(); }