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


Java EReference.setUpperBound方法代碼示例

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


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


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