本文整理匯總了Java中org.eclipse.emf.ecore.EReference.isMany方法的典型用法代碼示例。如果您正苦於以下問題:Java EReference.isMany方法的具體用法?Java EReference.isMany怎麽用?Java EReference.isMany使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.emf.ecore.EReference
的用法示例。
在下文中一共展示了EReference.isMany方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initOppositeInfo
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
private void initOppositeInfo() {
for (EClassifier eClassifier : ePackage.getEClassifiers()) {
if (eClassifier instanceof EClass) {
EClass eClass = (EClass)eClassifier;
boolean hasOpposites = false;
boolean hasManyOpposites = false;
for (EReference eReference : eClass.getEAllReferences()) {
if (eReference.getEOpposite() != null) {
hasOpposites = true;
if (eReference.isMany()) {
hasManyOpposites = true;
}
}
}
oppositeInfos.put(eClass, new OppositeInfo(hasOpposites, hasManyOpposites));
}
}
}
示例2: dumpPlusReferences
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private void dumpPlusReferences(Set<IdEObject> done, IdEObject idEObject) {
if (idEObject == null) {
return;
}
if (done.contains(idEObject)) {
return;
}
done.add(idEObject);
System.out.println(idEObject.getOid() + ": " + idEObject.eClass().getName());
for (EReference eReference : idEObject.eClass().getEAllReferences()) {
Object val = idEObject.eGet(eReference);
if (eReference.isMany()) {
List list = (List) val;
for (Object o : list) {
dumpPlusReferences(done, (IdEObject) o);
}
} else {
dumpPlusReferences(done, (IdEObject) val);
}
}
}
示例3: fixOids
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private void fixOids(IdEObject idEObject, OidProvider oidProvider, BiMap<Long, IdEObject> temp) {
if (idEObject == null) {
return;
}
if (temp.containsValue(idEObject)) {
return;
}
((IdEObjectImpl) idEObject).setOid(oidProvider.newOid(idEObject.eClass()));
if (objects.containsValue(idEObject)) {
temp.put(idEObject.getOid(), idEObject);
}
for (EReference eReference : idEObject.eClass().getEAllReferences()) {
Object val = idEObject.eGet(eReference);
if (eReference.isMany()) {
List list = (List) val;
for (Object o : list) {
fixOids((IdEObject) o, oidProvider, temp);
}
} else {
fixOids((IdEObject) val, oidProvider, temp);
}
}
}
示例4: resetOids
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public void resetOids(IdEObject idEObject, Set<IdEObject> done) {
if (idEObject == null) {
return;
}
if (done.contains(idEObject)) {
return;
}
((IdEObjectImpl) idEObject).setOid(-1);
done.add(idEObject);
for (EReference eReference : idEObject.eClass().getEAllReferences()) {
Object val = idEObject.eGet(eReference);
if (eReference.isMany()) {
List list = (List) val;
for (Object o : list) {
resetOids((IdEObject) o, done);
}
} else {
resetOids((IdEObject) val, done);
}
}
}
示例5: merge
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
private void merge(final EObject extension, final EObject extendsEObject, final Map<String, EObject> idToEObject) {
mergeAttributes(extension, extendsEObject);
mergeCrossReferences(extension, extendsEObject, idToEObject);
for (final EObject extensionChild : extension.eContents()) {
final String uriFragment = uriFragmentBuilder.getURIFragment(extensionChild);
if (idToEObject.containsKey(uriFragment)) {
final EObject extendsChild = idToEObject.get(uriFragment);
merge(extensionChild, extendsChild, idToEObject);
} else {
final EObject copy = copy(extensionChild);
final EReference containmentFeature = extensionChild.eContainmentFeature();
if (containmentFeature.isMany()) {
final List<EObject> containment = (List<EObject>) extendsEObject.eGet(containmentFeature);
containment.add(copy);
} else {
extendsEObject.eSet(containmentFeature, copy);
}
}
}
}
示例6: createEReferenceByAtoms
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
@SuppressWarnings({"unchecked", "rawtypes"})
private void createEReferenceByAtoms(String refName, String fromAtom, String toAtom)
throws TraceException {
EObject sourceAtom = atom2EClass.get(fromAtom);
EObject targetAtom = atom2EClass.get(toAtom);
for (EReference eReference : sourceAtom.eClass().getEAllReferences()) {
if (eReference.getName().equals(refName)) {
if (eReference.isMany()) {
((List) sourceAtom.eGet(eReference)).add(targetAtom);
} else {
sourceAtom.eSet(eReference, targetAtom);
}
break;
}
}
}
示例7: assertNoDanglingReferences
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
/**
* Asserts that root and the entire object tree below root does not contain any dangling references, i.e.
* cross-references to target {@link EObject}s that are not contained in a {@link Resource}.
*/
public void assertNoDanglingReferences(EObject root) {
final List<String> errMsgs = new ArrayList<>();
final TreeIterator<EObject> iter = root.eAllContents();
while (iter.hasNext()) {
final EObject currObj = iter.next();
if (currObj != null && !currObj.eIsProxy()) {
for (EReference currRef : currObj.eClass().getEAllReferences()) {
if (!currRef.isContainment() && !currRef.isContainer() && currRef.getEOpposite() == null) {
if (currRef.isMany()) {
@SuppressWarnings("unchecked")
final EList<? extends EObject> targets = (EList<? extends EObject>) currObj.eGet(currRef,
false);
for (EObject currTarget : targets) {
if (isDangling(currTarget)) {
errMsgs.add(getErrorInfoForDanglingEObject(currObj, currRef));
break;
}
}
} else {
final EObject target = (EObject) currObj.eGet(currRef, false);
if (isDangling(target))
errMsgs.add(getErrorInfoForDanglingEObject(currObj, currRef));
}
}
}
}
}
if (!errMsgs.isEmpty())
fail("Expected no dangling references, but found the following: " + Joiner.on("; ").join(errMsgs) + ".");
}
示例8: haveEqualReference
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
protected boolean haveEqualReference(EObject eObject1, EObject eObject2, EReference reference) {
Object value1 = eObject1.eGet(reference, false);
Object value2 = eObject2.eGet(reference, false);
return reference.isMany() ? equals((List<EObject>) value1, (List<EObject>) value2)
: equals((EObject) value1, (EObject) value2);
}
示例9: getConnectedEdgesForEObject
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
/**
* Add outgoing references
*/
private void getConnectedEdgesForEObject(Node node, final List<Node> allNodes, final List<Edge> result,
final EObject eobj) {
for (EReference currRef : eobj.eClass().getEAllReferences()) {
if (!currRef.isDerived() && !currRef.isContainer()) {
if (currRef.isMany()) {
final Object targets = eobj.eGet(currRef, false);
if (targets instanceof Collection<?>) {
getConnectedEdgesForEObjectManyCase(node, allNodes, result, currRef, targets);
}
} else {
final Object target = eobj.eGet(currRef, false);
if (target instanceof EObject) {
getConnectedEdgesForEObjectSingleCase(node, allNodes, result, currRef, target);
}
}
}
}
// add reference to containing Resource if immediate container is not in graph
// (required when showing lower-level objects while hiding their ancestors)
Node nodeForElement = GraphUtils.getNodeForElement(eobj.eContainer(), allNodes);
if (eobj.eResource() != null && eobj.eContainer() != null && nodeForElement == null) {
final Node nodeForResource = GraphUtils.getNodeForElement(eobj.eResource(), allNodes);
if (nodeForResource != null) {
Edge edge = new Edge(
"<... containment omitted ...>",
false, // not a cross-link
nodeForResource,
Collections.singletonList(node),
Collections.emptyList());
result.add(edge);
}
}
}
示例10: createAndSetProxy
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
/**
* Creates a proxy instance that will later on allow to lazily resolve the semantically referenced instance for the
* given {@link CrossReference xref}.
*/
@SuppressWarnings("unchecked")
private void createAndSetProxy(N4JSResource resource, EObject obj, INode node, EReference eRef,
CrossReference xref,
IDiagnosticProducer diagnosticProducer) {
final EObject proxy = createProxy(resource, obj, node, eRef, xref, diagnosticProducer);
proxy.eSetDeliver(false);
if (eRef.isMany()) {
((InternalEList<EObject>) obj.eGet(eRef, false)).addUnique(proxy);
} else {
obj.eSet(eRef, proxy);
}
}
示例11: dumpObject
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private void dumpObject(IdEObject idEObject, int indention, Set<IdEObject> printed) {
if (printed.contains(idEObject)) {
printIndention(indention);
System.out.println("[REFERENCE: " + idEObject.getOid() + "]");
return;
}
printed.add(idEObject);
printIndention(indention);
System.out.println(idEObject.eClass().getName() + " (" + idEObject.getOid() + ")");
for (EAttribute eAttribute : idEObject.eClass().getEAllAttributes()) {
Object val = idEObject.eGet(eAttribute);
if (val != null) {
printIndention(indention + 1);
System.out.println(eAttribute.getName() + ": " + val);
}
}
for (EReference eReference : idEObject.eClass().getEAllReferences()) {
Object referencedObject = idEObject.eGet(eReference);
if (eReference.isMany()) {
List list = (List) referencedObject;
if (list.size() > 0) {
printIndention(indention + 1);
System.out.println(eReference.getName() + ": ");
for (Object o : list) {
dumpObject((IdEObject) o, indention + 2, printed);
}
}
} else {
if (referencedObject != null) {
printIndention(indention + 1);
System.out.println(eReference.getName() + ": ");
dumpObject((IdEObject) referencedObject, indention + 2, printed);
}
}
}
}
示例12: checkDoubleOidsPlusReferences
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private void checkDoubleOidsPlusReferences(BiMap<IdEObject, Long> done, IdEObject idEObject) {
if (idEObject == null) {
return;
}
if (idEObject.eClass().getEAnnotation("wrapped") != null) {
return;
}
if (done.containsKey(idEObject)) {
return;
}
if (done.containsValue(idEObject.getOid())) {
showBackReferences(idEObject);
IdEObject existing = done.inverse().get(idEObject.getOid());
showBackReferences(existing);
throw new RuntimeException("Double oid: " + idEObject.getOid() + " " + idEObject + ", " + existing);
}
done.put(idEObject, idEObject.getOid());
for (EReference eReference : idEObject.eClass().getEAllReferences()) {
if (eReference.isMany()) {
List list = (List) idEObject.eGet(eReference);
for (Object o : list) {
checkDoubleOidsPlusReferences(done, (IdEObject) o);
}
} else {
checkDoubleOidsPlusReferences(done, (IdEObject) idEObject.eGet(eReference));
}
}
}
示例13: iterateAllObjects
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
public Iterator<IdEObject> iterateAllObjects() {
return new Iterator<IdEObject>() {
private final Queue<IdEObject> todo = new LinkedBlockingQueue<IdEObject>(getValues());
private final Set<IdEObject> done = new HashSet<IdEObject>();
@Override
public boolean hasNext() {
return !todo.isEmpty();
}
@SuppressWarnings("rawtypes")
@Override
public IdEObject next() {
IdEObject idEObject = todo.poll();
done.add(idEObject);
for (EReference eReference : idEObject.eClass().getEAllReferences()) {
Object val = idEObject.eGet(eReference);
if (eReference.isMany()) {
List list = (List) val;
for (Object o : list) {
if (!done.contains(o)) {
todo.add((IdEObject) o);
}
}
} else {
if (val != null && !done.contains(val)) {
todo.add((IdEObject) val);
}
}
}
return idEObject;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
示例14: fixInverses
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
@SuppressWarnings({ "unchecked", "unused" })
private void fixInverses(PackageMetaData packageMetaData, Integer rid) throws DatabaseException {
Map<Long, VirtualObject> cache = new HashMap<Long, VirtualObject>();
CloseableIterator<VirtualObject> objectIterator = virtualObjectService.streamByRid(rid);
while (objectIterator.hasNext()) {
VirtualObject next = objectIterator.next();
if (packageMetaData.hasInverses(next.eClass())) {
for (EReference eReference : packageMetaData.getAllHasInverseReferences(next.eClass())) {
Object reference = next.eGet(eReference);
if (reference != null) {
if (eReference.isMany()) {
List<Long> references = (List<Long>) reference;
for (Long refOid : references) {
fixInverses(packageMetaData, rid, cache, next, eReference, refOid);
}
} else {
fixInverses(packageMetaData, rid, cache, next, eReference, (Long) reference);
}
}
}
}
}
List<VirtualObject> section = new ArrayList<>();
for (VirtualObject virtualObject : cache.values()) {
section.add(virtualObject);
if (section.size() >= 1000) {
virtualObjectService.updateAllVirtualObject(section);
section.clear();
}
}
virtualObjectService.updateAllVirtualObject(section);
section.clear();
}
示例15: putIntoContainer
import org.eclipse.emf.ecore.EReference; //導入方法依賴的package包/類
/**
* Puts given dynamic EObject to corresponding container
*
* @param container
* @param eObject
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public static void putIntoContainer(EObject container, EObject eObject) {
for (EReference eReference : container.eClass().getEAllReferences()) {
if (eObject.eClass().getName().equals(eReference.getEReferenceType().getName())) {
if (eReference.isMany())
((List) container.eGet(eReference)).add(eObject);
else
container.eSet(eReference, eObject);
break;
}
}
}