org.eclipse.xtext.resource.IEObjectDescription Java Examples

The following examples show how to use org.eclipse.xtext.resource.IEObjectDescription. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BuiltInTypeScopeTest.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@SuppressWarnings("javadoc")
@Test
public void testLoadingBuiltInTypes() {
	BuiltInTypeScope scope = BuiltInTypeScope.get(resourceSet);
	IEObjectDescription anyType = scope.getSingleElement(QualifiedName.create("any"));
	Assert.assertNotNull(anyType);
	String s = "";
	for (Resource resource : resourceSet.getResources()) {
		if (resource.getErrors().size() > 0) {
			for (Diagnostic d : resource.getErrors()) {
				s += "\n  " + d.getMessage() + " at " + resource.getURI() + ":" + d.getLine();
			}
		}
	}

	Assert.assertEquals("Resources definine built-in types must have no error.", "", s);
}
 
Example #2
Source File: PrefixedContainerBasedScope.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
@SuppressWarnings("PMD.UseLocaleWithCaseConversions")
@Override
public synchronized IEObjectDescription getSingleElement(final QualifiedName name) {
  final boolean ignoreCase = isIgnoreCase();
  final QualifiedName lookupName = ignoreCase ? name.toLowerCase() : name;
  final IEObjectDescription result = contentByNameCache.get(lookupName);
  if (result != null && result != NULL_DESCRIPTION) {
    return result;
  } else if (result == null) {
    final ContainerQuery copy = ((ContainerQuery.Builder) criteria).copy().name(prefix.append(lookupName)).ignoreCase(ignoreCase);
    final Iterable<IEObjectDescription> res = copy.execute(container);
    IEObjectDescription desc = Iterables.getFirst(res, null);
    if (desc != null) {
      IEObjectDescription aliased = new AliasingEObjectDescription(name, desc);
      contentByNameCache.put(lookupName, aliased);
      return aliased;
    }
    contentByNameCache.put(lookupName, NULL_DESCRIPTION);
  }

  // in case of aliasing revert to normal ContainerBasedScope behavior (using name pattern)
  if (nameFunctions.size() > 1) {
    return super.getSingleElement(name);
  }
  return getParent().getSingleElement(name);
}
 
Example #3
Source File: NestedTypesScope.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
protected IEObjectDescription doGetSingleElement(JvmDeclaredType declarator, QualifiedName name, String firstSegment, int dollarIndex) {
	if (declarator.isLocal()) {
		JvmTypeReference superTypeReference = Iterables.getLast(declarator.getSuperTypes());
		if (InferredTypeIndicator.isInferred(superTypeReference))
			return findNestedTypeInLocalTypeNonResolving(declarator, name, firstSegment, dollarIndex);
	}
	
	Iterable<JvmDeclaredType> nestedTypes = declarator.findAllNestedTypesByName(firstSegment);
	for(JvmDeclaredType nested: nestedTypes) {
		JvmType nestedType = findNestedType(nested, 0, name);
		if (nestedType != null) {
			return toDescription(name, nestedType, dollarIndex, 0);
		}
	}
	return null;
}
 
Example #4
Source File: SuperCallScopeTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testGetElementsByEObject_01() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("generate test \'http://test\'");
  _builder.newLine();
  _builder.append("Rule: name=ID;");
  _builder.newLine();
  _builder.append("terminal ID: super;");
  _builder.newLine();
  final String grammarAsString = _builder.toString();
  EObject _model = this.getModel(grammarAsString);
  final Grammar grammar = ((Grammar) _model);
  final SuperCallScope scope = new SuperCallScope(grammar);
  final AbstractRule id = GrammarUtil.findRuleForName(grammar, "test.Lang.ID");
  Iterable<IEObjectDescription> _elements = scope.getElements(id);
  AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "test.Lang.ID");
  Pair<String, AbstractRule> _mappedTo = Pair.<String, AbstractRule>of("Lang.ID", _findRuleForName);
  AbstractRule _findRuleForName_1 = GrammarUtil.findRuleForName(grammar, "test.Lang.ID");
  Pair<String, AbstractRule> _mappedTo_1 = Pair.<String, AbstractRule>of("test.Lang.ID", _findRuleForName_1);
  this.assertElements(_elements, _mappedTo, _mappedTo_1);
}
 
Example #5
Source File: XtextScopeProvider.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
protected IScope createScope(final Grammar grammar, EClass type, IScope current) {
	if (EcorePackage.Literals.EPACKAGE == type) {
		return createEPackageScope(grammar);
	} else if (AbstractMetamodelDeclaration.class.isAssignableFrom(type.getInstanceClass())) {
		return new SimpleScope(IScope.NULLSCOPE,Iterables.transform(grammar.getMetamodelDeclarations(),
						new Function<AbstractMetamodelDeclaration,IEObjectDescription>(){
							@Override
							public IEObjectDescription apply(AbstractMetamodelDeclaration from) {
								String name = from.getAlias() != null ? from.getAlias() : "";
								return EObjectDescription.create(QualifiedName.create(name), from);
							}
						}));
	}
	final List<Grammar> allGrammars = getAllGrammars(grammar);
	for (int i = allGrammars.size() - 1; i >= 0; i--) {
		current = doCreateScope(allGrammars.get(i), type, current);
	}
	return current;
}
 
Example #6
Source File: XbaseProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void createReceiverProposals(XExpression receiver, CrossReference crossReference, ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor) {
//		long time = System.currentTimeMillis();
		String ruleName = getConcreteSyntaxRuleName(crossReference);
		Function<IEObjectDescription, ICompletionProposal> proposalFactory = getProposalFactory(ruleName, contentAssistContext);
		IResolvedTypes resolvedTypes = typeResolver.resolveTypes(receiver);
		LightweightTypeReference receiverType = resolvedTypes.getActualType(receiver);
		if (receiverType == null || receiverType.isPrimitiveVoid()) {
			return;
		}
		IExpressionScope expressionScope = resolvedTypes.getExpressionScope(receiver, IExpressionScope.Anchor.RECEIVER);
		// TODO exploit the type name information
		IScope scope;
		if (contentAssistContext.getCurrentModel() != receiver) {
			EObject currentModel = contentAssistContext.getCurrentModel();
			if (currentModel instanceof XMemberFeatureCall && ((XMemberFeatureCall) currentModel).getMemberCallTarget() == receiver) {
				scope = filterByConcreteSyntax(expressionScope.getFeatureScope((XAbstractFeatureCall) currentModel), crossReference);
			} else {
				scope = filterByConcreteSyntax(expressionScope.getFeatureScope(), crossReference);
			}
		} else {
			scope = filterByConcreteSyntax(expressionScope.getFeatureScope(), crossReference);
		}
		getCrossReferenceProposalCreator().lookupCrossReference(scope, receiver, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, acceptor, getFeatureDescriptionPredicate(contentAssistContext), proposalFactory);
//		System.out.printf("XbaseProposalProvider.createReceiverProposals = %d\n", System.currentTimeMillis() - time);
	}
 
Example #7
Source File: DefaultResourceDescriptionTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testGetExportedObject_2() throws Exception {
	strategy.setQualifiedNameProvider(new IQualifiedNameProvider.AbstractImpl() {
		@Override
		public QualifiedName getFullyQualifiedName(EObject obj) {
			if (obj instanceof EClassifier)
				return QualifiedName.create(((EClassifier) obj).getName());
			return null;
		}
	});

	Iterable<IEObjectDescription> iterable = description.getExportedObjects();
	ArrayList<IEObjectDescription> list = Lists.newArrayList(iterable);
	assertEquals(2, list.size());
	assertEquals(eClass.getName(), list.get(0).getName().toString());
	assertEquals(eClass, list.get(0).getEObjectOrProxy());
	assertEquals(dtype.getName(), list.get(1).getName().toString());
	assertEquals(dtype, list.get(1).getEObjectOrProxy());
}
 
Example #8
Source File: XbaseIdeContentProposalPriorities.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public int getCrossRefPriority(IEObjectDescription objectDesc, ContentAssistEntry entry) {
	if (entry != null) {
		if (objectDesc instanceof SimpleIdentifiableElementDescription) {
			if (!"this".equals(entry.getProposal()) && !"super".equals(entry.getProposal())) {
				return adjustPriority(entry, getCrossRefPriority() + 70);
			}
		} else if (objectDesc instanceof StaticFeatureDescriptionWithTypeLiteralReceiver) {
			return adjustPriority(entry, getCrossRefPriority() + 60);
		} else if (objectDesc instanceof IIdentifiableElementDescription) {
			JvmIdentifiableElement element = ((IIdentifiableElementDescription) objectDesc).getElementOrProxy();
			if (element instanceof JvmField) {
				return adjustPriority(entry, getCrossRefPriority() + 50);
			} else if (element instanceof JvmExecutable) {
				return adjustPriority(entry, getCrossRefPriority() + 20);
			}
		}
	}
	return super.getCrossRefPriority(objectDesc, entry);
}
 
Example #9
Source File: LiveShadowedChunkedContainerTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testDeleteElement() {
  try {
    this._parseHelper.parse("foo", this.fooURI, this.rs1).eResource().getContents().clear();
    final Function1<IEObjectDescription, String> _function = (IEObjectDescription it) -> {
      return it.getQualifiedName().toString();
    };
    Assert.assertEquals("", IterableExtensions.join(IterableExtensions.<IEObjectDescription, String>map(this.fooContainer.getExportedObjects(), _function), ","));
    Assert.assertEquals(1, IterableExtensions.size(this.fooContainer.getResourceDescriptions()));
    Assert.assertEquals(1, this.fooContainer.getResourceDescriptionCount());
    Assert.assertEquals(0, IterableExtensions.size(this.fooContainer.getExportedObjects()));
    Assert.assertEquals(1, IterableExtensions.size(this.barContainer.getResourceDescriptions()));
    Assert.assertEquals(1, this.barContainer.getResourceDescriptionCount());
    this.assertGlobalDescriptionsAreUnaffected();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #10
Source File: ExpressionScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Iterable<IEObjectDescription> getElements(QualifiedName name) {
	ensureInitialized();
	List<IEObjectDescription> result = allElementsByName.get(name);
	if (result != null) {
		return result;
	}
	return Collections.emptyList();
}
 
Example #11
Source File: IntersectionMemberDescriptionWithError.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected boolean initMessageAndCode(List<String> missingFrom, MapOfIndexes<String> indexesPerMemberType,
		QualifiedName name, boolean readOnlyField, IEObjectDescription[] descriptions,
		MapOfIndexes<String> indexesPerCode) {

	return initMemberTypeConflict(indexesPerMemberType)
			|| initSubMessages(descriptions, indexesPerCode)
			|| initDefault();
}
 
Example #12
Source File: AbstractConstructorScopeTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testGetElementByName_07() {
	IEObjectDescription hashMapEntry = getConstructorScope().getSingleElement(QualifiedName.create("java", "util", "Hashtable", "Entry"));
	assertNotNull(hashMapEntry);
	assertFalse(hashMapEntry.getEObjectOrProxy().eIsProxy());
	assertEquals(TypesPackage.Literals.JVM_CONSTRUCTOR, hashMapEntry.getEClass());
	assertEquals(QualifiedName.create("java", "util", "Hashtable", "Entry"), hashMapEntry.getName());
}
 
Example #13
Source File: MapBasedScope.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Iterable<IEObjectDescription> getLocalElementsByName(QualifiedName name) {
	IEObjectDescription result = null;
	if (isIgnoreCase()) {
		result = elements.get(name.toLowerCase());
	} else {
		result = elements.get(name);
	}
	if (result == null)
		return Collections.emptyList();
	return Collections.singleton(result);
}
 
Example #14
Source File: MonitoredClusteringBuilderState.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Iterable<IResourceDescription> findExactReferencingResources(final Set<IEObjectDescription> targetObjects, final ReferenceMatchPolicy matchPolicy) {
  Pair<Set<IEObjectDescription>, ReferenceMatchPolicy> key = Tuples.create(targetObjects, matchPolicy);
  Iterable<IResourceDescription> result = findExactReferencingResourcesCache.get(key);
  if (result == null) {
    result = Lists.newArrayList(delegate().findExactReferencingResources(targetObjects, matchPolicy));
    findExactReferencingResourcesCache.put(key, result);
  }
  return result;
}
 
Example #15
Source File: N4JSIdeContentProposalProvider.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * For type proposals, use a dedicated proposal creator that will query the scope, filter it and apply the proposal
 * factory to all applicable {@link IEObjectDescription descriptions}.
 */
protected void lookupCrossReference(EReference reference, ContentAssistContext context,
		IIdeContentProposalAcceptor acceptor, Predicate<IEObjectDescription> filter) {

	if (reference.getEReferenceType().isSuperTypeOf(TypesPackage.Literals.TYPE)
			|| TypesPackage.Literals.TYPE.isSuperTypeOf(reference.getEReferenceType())) {

		EObject model = context.getCurrentModel();
		importsAwareReferenceProposalCreator.lookupCrossReference(model, reference, context, acceptor, filter);
	}
}
 
Example #16
Source File: JvmTypesAwareDirtyStateEditorSupport.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void processDelta(IResourceDescription.Delta delta, Resource context, List<Resource> result) {
	super.processDelta(delta, context, result);
	ResourceSet resourceSet = context.getResourceSet();
	if(delta.getNew() != null){
		Iterable<IEObjectDescription> exportedJvmTypes = delta.getNew().getExportedObjectsByType(TypesPackage.Literals.JVM_GENERIC_TYPE);
		for(IEObjectDescription jvmTypeDesc : exportedJvmTypes){
			URI uriToJvmType = URIHelperConstants.OBJECTS_URI.appendSegment(jvmTypeDesc.getQualifiedName().toString());
			Resource jvmResourceInResourceSet = resourceSet.getResource(uriToJvmType, false);
			if(jvmResourceInResourceSet != null)
				result.add(jvmResourceInResourceSet);
		}
	}
}
 
Example #17
Source File: ResourceSetBasedResourceDescriptionsTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testPerformance10Resources100EClassesEach() {
	int resourceCount = 10;
	int eClassCount = 100;
	for(int i = 0; i < resourceCount; i++) {
		Resource resource = createResource();
		for(int j = 0; j < eClassCount; j++) {
			createNamedElement(null, EcorePackage.Literals.ECLASS, resource);
		}
	}
	Iterable<IEObjectDescription> iterable = container.getExportedObjectsByType(EcorePackage.Literals.EDATA_TYPE);
	assertTrue(Iterables.isEmpty(iterable));
	iterable = container.getExportedObjectsByType(EcorePackage.Literals.ECLASS);
	assertEquals(resourceCount*eClassCount, Iterables.size(iterable));
}
 
Example #18
Source File: ImportScopeTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testDuplicatesNotVisible_02_IgnoreCase() throws Exception {
	final IEObjectDescription desc1 = new EObjectDescription(QualifiedName.create("com","foo"), EcorePackage.Literals.EANNOTATION, null);
	final IEObjectDescription desc2 = new EObjectDescription(QualifiedName.create("de","Foo"), EcorePackage.Literals.EATTRIBUTE, null);
	SimpleScope outer = new SimpleScope(newArrayList(desc1,desc2), true);
	ImportNormalizer n1 = new ImportNormalizer(QualifiedName.create("COM"), true, true);
	ImportNormalizer n2 = new ImportNormalizer(QualifiedName.create("DE"), true, true);
	TestableImportScope scope = new TestableImportScope(newArrayList(n1,n2), outer, new ScopeBasedSelectable(outer), EcorePackage.Literals.EOBJECT, true);
	
	Iterator<IEObjectDescription> iterator = scope.getAllElements().iterator();
	assertSame(desc1,iterator.next());
	assertSame(desc2,iterator.next());
	assertFalse(iterator.hasNext());
}
 
Example #19
Source File: ReceiverFeatureScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected IEObjectDescription createDescription(QualifiedName name, JvmFeature feature, TypeBucket bucket) {
	if (implicit) {
		return new InstanceFeatureDescriptionWithImplicitReceiver(name, feature, receiver, receiverType, getReceiverTypeParameterMapping(), bucket.getFlags(), bucket.getId(), isVisible(feature), validStaticState);
	} else {
		return new InstanceFeatureDescription(name, feature, receiver, receiverType, getReceiverTypeParameterMapping(), bucket.getFlags(), bucket.getId(), isVisible(feature));
	}
}
 
Example #20
Source File: AbstractConstructorScopeTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testGetElementsByName_03() {
	List<String> segments = Strings.split("org.eclipse.xtext.common.types.testSetups.NestedParameterizedTypes.WrappedCollection.WrappedIterator", '.');
	QualifiedName qualifiedName = QualifiedName.create(segments);
	Iterable<IEObjectDescription> descriptions = getConstructorScope().getElements(qualifiedName);
	for(IEObjectDescription description: descriptions) {
		assertEquals(qualifiedName, description.getName());
	}
	assertEquals(3, Iterables.size(descriptions));
}
 
Example #21
Source File: ArithmeticsCallHierarchyBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected IEObjectDescription findDeclaration(URI objectURI) {
	IEObjectDescription description = this.getDescription(objectURI);
	EClass eClass = null;
	if (description != null) {
		eClass = description.getEClass();
	}
	if (this.isDefinition(eClass)) {
		return description;
	}
	return readOnly(objectURI, (EObject object) -> {
		AbstractDefinition abstractDefinition = EcoreUtil2.getContainerOfType(object, AbstractDefinition.class);
		return getDescription(abstractDefinition);
	});
}
 
Example #22
Source File: N4JSResourceDescriptionStrategy.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/** @return the final modifier of the given description. */
public static boolean getFinal(IEObjectDescription description) {
	String userData = description.getUserData(FINAL_KEY);
	if (userData == null) {
		return FINAL_DEFAULT;
	}
	return Boolean.parseBoolean(userData);
}
 
Example #23
Source File: RecordingTypeScope.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IEObjectDescription getSingleElement(QualifiedName name) {
	importedNames.add(name.toLowerCase());
	IEObjectDescription element = typeScope.getSingleElement(name);
	if (element == null) {
		ClassNameVariants nameVariants = new ClassNameVariants(name.toString());
		while (nameVariants.hasNext()) {
			String nextVariant = nameVariants.next();
			importedNames.add(getQualifiedNameConverter().toQualifiedName(nextVariant).toLowerCase());
		}
	}
	return element;
}
 
Example #24
Source File: UserDataAwareScope.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Iterable<IEObjectDescription> getAllElements() {
	Iterable<IEObjectDescription> parent = super.getAllElements();
	return Iterables.transform(parent, new Function<IEObjectDescription, IEObjectDescription>() {
		@Override
		public IEObjectDescription apply(IEObjectDescription input) {
			return lazyResolve(input);
		}
	});
}
 
Example #25
Source File: XtextLinkingService.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
private EPackage findPackageInScope(EObject context, QualifiedName packageNsURI) {
	IScope scopedPackages = scopeProvider.getScope(context.eResource(), XtextPackage.Literals.ABSTRACT_METAMODEL_DECLARATION__EPACKAGE, new Predicate<IEObjectDescription>() {
		@Override
		public boolean apply(IEObjectDescription input) {
			return isNsUriIndexEntry(input);
		}
	});
	IEObjectDescription description = scopedPackages.getSingleElement(packageNsURI);
	if (description != null) {
		return getResolvedEPackage(description, context);
	}
	return null;
}
 
Example #26
Source File: STextGlobalScopeProvider.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected IScope filterPropertiesOfLibrary(Resource context, EReference reference,
		Predicate<IEObjectDescription> filter) {
	return new FilteringScope(libraryScope.getScope(context, reference, filter),
			new Predicate<IEObjectDescription>() {
				@Override
				public boolean apply(IEObjectDescription input) {
					return input.getEClass() != TypesPackage.Literals.PROPERTY;
				}
			});
}
 
Example #27
Source File: STextNamesAreUniqueValidationHelper.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void validateCapitonym(IEObjectDescription description, IEObjectDescription doublet,
		ValidationMessageAcceptor acceptor) {
	if (inSameResource(doublet, description) && doublet.getEClass().equals(description.getEClass())) {
		createDuplicateNameWarning(description, description.getEClass(), acceptor);
		createDuplicateNameWarning(doublet, description.getEClass(), acceptor);
	}
}
 
Example #28
Source File: ImportedNamesAdapter.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Iterable<IEObjectDescription> getElements(final QualifiedName name) {
	return new Iterable<IEObjectDescription>() {
		@Override
		public Iterator<IEObjectDescription> iterator() {
			final QualifiedName lowerCase = name.toLowerCase();
			importedNames.add(lowerCase);
			final Iterable<IEObjectDescription> elements = delegate.getElements(name);
			return elements.iterator();
		}
	};
}
 
Example #29
Source File: AbstractConstructorScopeTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testGetElementByInstance_04() {
	QualifiedName qualifiedName = QualifiedName.create("java", "util", "Hashtable", "Entry");
	IEObjectDescription hashMapEntry = getConstructorScope().getSingleElement(qualifiedName);
	JvmConstructor constructor = (JvmConstructor) hashMapEntry.getEObjectOrProxy();
	IEObjectDescription element = getConstructorScope().getSingleElement(constructor);
	assertNotNull(element);
	assertEquals(qualifiedName, element.getName());
}
 
Example #30
Source File: ExpressionScopeTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void assertContains(IScope scope, QualifiedName name) {
	Iterable<IEObjectDescription> elements = scope.getAllElements();
	String toString = elements.toString();
	assertNotNull(toString, scope.getSingleElement(name));
	assertFalse(toString, Iterables.isEmpty(scope.getElements(name)));
	assertTrue(toString, IterableExtensions.exists(elements, it -> Objects.equal(it.getName(), name)));
}