當前位置: 首頁>>代碼示例>>Java>>正文


Java EReference.setEType方法代碼示例

本文整理匯總了Java中org.eclipse.emf.ecore.EReference.setEType方法的典型用法代碼示例。如果您正苦於以下問題:Java EReference.setEType方法的具體用法?Java EReference.setEType怎麽用?Java EReference.setEType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.emf.ecore.EReference的用法示例。


在下文中一共展示了EReference.setEType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: completeRecordTypeFeatures

import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
private void completeRecordTypeFeatures(RecordType recordType, EClass type) {

		for (RecordField rf : recordType.getRecordFields()) {
			// if the type of the recordField is different to arraytype or a recordtype
			// it will be translated into a EMF attribute
			if (!(rf.getType() instanceof RecordType || rf.getType() instanceof ArrayType)) {
				EAttribute attribute = EcoreFactory.eINSTANCE.createEAttribute();
				type.getEStructuralFeatures().add(attribute);
				attribute.setName(rf.getName());
				attribute.setLowerBound(1);
				attribute.setEType(getMappedType(rf.getType()));
				
				// Set the default value of the Ecore attribute.
				String defaultValue = rf.getDefault();
				if (defaultValue != null && !defaultValue.isEmpty()) {
					attribute.setDefaultValue(defaultValue);
				}
				// The Ecore attribute is required when the OCCI attribute is required.
				if (attribute.isRequired()) {
					attribute.setLowerBound(1);
				}
				attachInfo(attribute, rf.getDescription());
				
			} else {
				// otherwise, il will be translated into an EMF reference
				EReference reference = EcoreFactory.eINSTANCE.createEReference();
				type.getEStructuralFeatures().add(reference);
				reference.setName(rf.getName());
				
				// The Ecore attribute is required when the OCCI attribute is required.
				if (rf.isRequired()) {
					reference.setLowerBound(1);
				}
				
				reference.setUpperBound(1);
				reference.setEType(getMappedType(rf.getType()));
				reference.setContainment(true);
				
				// Set the default value of the Ecore attribute.
				// Default values for EMF EReference is not supported
				// see https://www.eclipse.org/forums/index.php?t=msg&th=131049&goto=406266&#msg_406266 
//				String defaultValue = rf.getDefault();
//				if (defaultValue != null && !defaultValue.isEmpty()) {
//					reference.setDefaultValue(defaultValue);
//				}
				
				attachInfo(reference, rf.getDescription());
				
			}
		}
	}
 
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:52,代碼來源:OCCIExtension2Ecore.java

示例2: convertAttribute

import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
/**
 * Convert an OCCI attribute to an Ecore attribute.
 * 
 * @param attribute
 *            the OCCI attribute to convert.
 * @return the resulting Ecore attribute.
 */
protected EStructuralFeature convertAttribute(Attribute attribute) {
	if(attribute.getType() instanceof BasicType || attribute.getType() instanceof EnumerationType) {
	// Create an Ecore attribute.
	EAttribute eAttr = EcoreFactory.eINSTANCE.createEAttribute();
	// Set the name of the Ecore attribute.
	eAttr.setName(Occi2Ecore.convertOcciAttributeName2EcoreAttributeName(attribute.getName()));
	// Set the type of the Ecore attribute.
	eAttr.setEType(getMappedType(attribute.getType()));
	// Set the default value of the Ecore attribute.
	String defaultValue = attribute.getDefault();
	if (defaultValue != null && !defaultValue.isEmpty()) {
		eAttr.setDefaultValue(defaultValue);
	}
	// The Ecore attribute is required when the OCCI attribute is required.
	if (attribute.isRequired()) {
		eAttr.setLowerBound(1);
	}
	attachInfo(eAttr, attribute.getDescription());
	return eAttr;
	}
	else {
		// Create an Ecore reference.
		EReference eRef = EcoreFactory.eINSTANCE.createEReference();
		// Set the name of the Ecore reference.
		eRef.setName(Occi2Ecore.convertOcciAttributeName2EcoreAttributeName(attribute.getName()));
		// Set the type of the Ecore reference.
		eRef.setEType(getMappedType(attribute.getType()));
		// Set the containment of the Ecore reference to true.
		eRef.setContainment(true);
		// The Ecore reference is required when the OCCI attribute is required.
		if (attribute.isRequired()) {
			eRef.setLowerBound(1);
		}
		attachInfo(eRef, attribute.getDescription());
		return eRef;
	}
}
 
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:45,代碼來源:OCCIExtension2Ecore.java


注:本文中的org.eclipse.emf.ecore.EReference.setEType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。