@Override public Object caseEnumerationLiteral( EnumerationLiteral enumerationLiteral) { setName(eNamedElement, enumerationLiteral.getName(), false); return enumerationLiteral; }
Slot findSlotByName(String name, EnumerationLiteral enumLiteral) { EList<Slot> slots = enumLiteral.getSlots(); for (Slot slot : slots) { Property property = (Property) slot.getDefiningFeature(); String slotPropertyName = property.getName(); if (slotPropertyName.equals(name)) { // We found it return slot; } } // We finished but cannot find it return null; }
/** * @see org.andromda.metafacades.uml.EnumerationLiteralFacade#getValue(boolean) */ @Override protected String handleGetValue(final boolean modelValue) { String value = null; if (this.metaObject.getSpecification() != null && this.metaObject.getSpecification() instanceof OpaqueExpression) { final OpaqueExpression expression = (OpaqueExpression)this.metaObject.getSpecification(); if (expression.getBodies() != null && !expression.getBodies().isEmpty()) { value = expression.getBodies().get(0); } } if (value == null) { value = this.getName(modelValue); } return StringUtils.trimToEmpty(value); }
/** * Callback for an EnumLiteralExp visit. * * @param el the enumeration literal expresion * @return the enumeration literal toString() */ @Override public String visitEnumLiteralExp(EnumLiteralExp<Classifier, EnumerationLiteral> el) { EnumerationLiteral l = el.getReferredEnumLiteral(); this.ojClass.addToImports(UmlgClassOperations.getPathName(l.getClassifier())); return UmlgClassOperations.getPathName(l.getClassifier()).getLast() + "." + l.getName(); }
when(enumIter.hasNext()).thenReturn(true).thenReturn(false); when(enumIter.next()).thenReturn(enumLiteral); when(enumLiteral.getName()).thenReturn("Home"); when(enumLiteral.getSlots()).thenReturn(slots); when(slots.iterator()).thenReturn(slotIter); when(slotIter.hasNext()).thenReturn(true).thenReturn(false);
@Override public Object caseEnumerationLiteral( EnumerationLiteral enumerationLiteral) { Enumeration enumeration = enumerationLiteral.getEnumeration(); if (enumeration != null) { EEnumLiteral eEnumLiteral = EcoreFactory.eINSTANCE .createEEnumLiteral(); elementToEModelElementMap.put(enumerationLiteral, eEnumLiteral); EEnum eEnum = (EEnum) doSwitch(enumeration); eEnum.getELiterals().add(eEnumLiteral); setName(eEnumLiteral, enumerationLiteral); int value = enumeration.getOwnedLiterals().indexOf( enumerationLiteral); ValueSpecification specification = enumerationLiteral .getSpecification(); if (specification != null) { try { value = specification.integerValue(); } catch (Exception e) { // ignore } } eEnumLiteral.setValue(value); defaultCase(enumerationLiteral); return eEnumLiteral; } return super.caseEnumerationLiteral(enumerationLiteral); }
public Classifier getEnumeration(EnumerationLiteral enumerationLiteral) { return enumerationLiteral.getEnumeration(); }
@Override public Object caseEEnumLiteral(EEnumLiteral eEnumLiteral) { EEnum eEnum = eEnumLiteral.getEEnum(); if (eEnum != null) { EnumerationLiteral enumerationLiteral = UMLFactory.eINSTANCE .createEnumerationLiteral(); eModelElementToElementMap.put(eEnumLiteral, enumerationLiteral); Enumeration enumeration = (Enumeration) doSwitch(eEnum); enumeration.getOwnedLiterals().add(enumerationLiteral); enumerationLiteral.setName(eEnumLiteral.getName()); int value = eEnumLiteral.getValue(); if (value != eEnum.getELiterals().indexOf(eEnumLiteral)) { ((LiteralInteger) enumerationLiteral.createSpecification( null, null, UMLPackage.Literals.LITERAL_INTEGER)) .setValue(value); } defaultCase(eEnumLiteral); return enumerationLiteral; } return super.caseEEnumLiteral(eEnumLiteral); }
when(enumIter.hasNext()).thenReturn(true).thenReturn(false); when(enumIter.next()).thenReturn(enumLiteral); when(enumLiteral.getName()).thenReturn("Home"); when(enumLiteral.getSlots()).thenReturn(slots); when(slots.iterator()).thenReturn(slotIter); when(slotIter.hasNext()).thenReturn(true).thenReturn(false);
/** * Default implementation just gets the name of the named element's * {@link org.eclipse.emf.ecore.EObject#eClass() metaclass} or, if it is a * {@link TypedElement}, the name of its type. */ public String getDescription(Object namedElement) { if (namedElement instanceof TypedElement) { Type type = ((TypedElement) namedElement).getType(); return (type == null) ? OCLStandardLibraryImpl.INSTANCE .getOclVoid().getName() : type.getName(); } else if (namedElement instanceof EnumerationLiteral) { return ((EnumerationLiteral) namedElement).getEnumeration() .getName(); } else if (namedElement == null) { return null; } return ((EObject) namedElement).eClass().getName(); }
when(enumIter.hasNext()).thenReturn(true).thenReturn(false); when(enumIter.next()).thenReturn(enumLiteral); when(enumLiteral.getName()).thenReturn("Home"); when(enumLiteral.getSlots()).thenReturn(slots); when(slots.iterator()).thenReturn(slotIter); when(slotIter.hasNext()).thenReturn(true).thenReturn(false);
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EnumerationLiteral getOwnedLiteral(String name, boolean ignoreCase, boolean createOnDemand) { ownedLiteralLoop : for (EnumerationLiteral ownedLiteral : getOwnedLiterals()) { if (name != null && !(ignoreCase ? name.equalsIgnoreCase(ownedLiteral.getName()) : name.equals(ownedLiteral.getName()))) continue ownedLiteralLoop; return ownedLiteral; } return createOnDemand ? createOwnedLiteral(name) : null; }
/** * @see org.andromda.metafacades.uml.EnumerationLiteralFacade#getValue(boolean) */ @Override protected String handleGetValue(final boolean modelValue) { String value = null; if (this.metaObject.getSpecification() != null && this.metaObject.getSpecification() instanceof OpaqueExpression) { final OpaqueExpression expression = (OpaqueExpression)this.metaObject.getSpecification(); if (expression.getBodies() != null && !expression.getBodies().isEmpty()) { value = expression.getBodies().get(0); } } if (value == null) { value = this.getName(modelValue); } return StringUtils.trimToEmpty(value); }
private void getSlotsNotIntelligent(AST ast, EnumerationLiteral enumLiteral, EnumConstantDeclaration ec) { EList<Slot> slots = enumLiteral.getSlots(); for (Slot slot : slots) { Property property = (Property) slot.getDefiningFeature(); Type type = property.getType(); chooseLiteralTypeAndAddToEnumConstantArguments(ast, ec, slot, type); } }
/** * Implements the interface by finding the corresponding <tt>Enumerator</tt> * value in a generated (or dynamic) EMF implementation, else the same * enumeration literal (supporting the instance-specification model case). * * @since 1.2 */ public Object getValue(EnumerationLiteral enumerationLiteral) { if (getEffectiveEvaluationMode() == EvaluationMode.RUNTIME_OBJECTS) { Object context = getValueOf(Environment.SELF_VARIABLE_NAME); // if we're in an instance-specification world (model of instances) // then we use the models of enumeration literals (M1 level), not // the run-time instances (M0 level) Enumeration umlEnum = enumerationLiteral.getEnumeration(); EClassifier eType = OCLUMLUtil.getEClassifier(umlEnum, context, getEPackageRegistry()); if (eType instanceof EEnum) { EEnumLiteral eLiteral = ((EEnum) eType).getELiterals().get( umlEnum.getOwnedLiterals().indexOf(enumerationLiteral)); if (eLiteral != null) { return eLiteral.getInstance(); } } } return enumerationLiteral; }
when(enumIter.hasNext()).thenReturn(true).thenReturn(false); when(enumIter.next()).thenReturn(enumLiteral); when(enumLiteral.getName()).thenReturn("Home"); when(enumLiteral.getSlots()).thenReturn(slots); when(slots.iterator()).thenReturn(slotIter); when(slotIter.hasNext()).thenReturn(true).thenReturn(false);
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public static String stringValue(InstanceValue instanceValue) { InstanceSpecification instance = instanceValue.getInstance(); if (instance instanceof EnumerationLiteral) { return ((EnumerationLiteral) instance).getName(); } else if (instance != null) { ValueSpecification specification = instance.getSpecification(); if (specification != null) { return specification.stringValue(); } } return ValueSpecificationOperations.stringValue(instanceValue); }
@SuppressWarnings("unchecked") @Test public void testFindSlotByNameFoundIt() { EnumerationLiteral enumLiteral = mock(EnumerationLiteral.class); EList<Slot> slots = mock(EList.class, Answers.RETURNS_DEEP_STUBS.get()); Iterator<Slot> slotIter = mock(Iterator.class); Slot slot1 = mock(Slot.class); Slot slot2 = mock(Slot.class); Property property1 = mock(Property.class); Property property2 = mock(Property.class); when(enumLiteral.getSlots()).thenReturn(slots); when(slots.iterator()).thenReturn(slotIter); when(slotIter.hasNext()).thenReturn(true).thenReturn(true) .thenReturn(false); when(slotIter.next()).thenReturn(slot1).thenReturn(slot2); when(slot1.getDefiningFeature()).thenReturn(property1); when(slot2.getDefiningFeature()).thenReturn(property2); when(property1.getName()).thenReturn("test1"); when(property2.getName()).thenReturn("test2"); Slot slotResult = enumGenerator.findSlotByName("test1", enumLiteral); assertEquals(slot1, slotResult); }
.getEnumeration(); .getEnumeration(); } else if (propertyName == TAG_DEFINITION__VISIBILITY) { Enumeration visibilityKindEnumeration = ((EnumerationLiteral) value) .getEnumeration();
when(enumIter.hasNext()).thenReturn(true).thenReturn(false); when(enumIter.next()).thenReturn(enumLiteral); when(enumLiteral.getName()).thenReturn("Home"); when(enumLiteral.getSlots()).thenReturn(slots1).thenReturn(slots2); when(slots1.iterator()).thenReturn(slotIter1); when(slots2.iterator()).thenReturn(slotIter2);