@Beta public class LocalUniqueNameContext extends java.lang.Object implements INamesAreUniqueValidationHelper.Context, ISelectable
A case-sensitive, local validation context to check unique names in the contents of
a container EObject or within a list.
class MyDslValidator extends AbstractDeclarativeValidator {
@Inject
private INamesAreUniqueValidationHelper helper;
@Check
public void checkUniqueNames(Model model) {
helper.checkUniqueNames(new LocalUniqueNameContext(model, getCancelIndicator()), this);
}
}
INamesAreUniqueValidationHelper.checkUniqueNames(Context, ValidationMessageAcceptor)| Constructor and Description |
|---|
LocalUniqueNameContext(org.eclipse.emf.ecore.EObject container,
boolean deep,
org.eclipse.xtext.util.CancelIndicator ci) |
LocalUniqueNameContext(org.eclipse.emf.ecore.EObject container,
boolean deep,
java.util.function.Function<org.eclipse.emf.ecore.EObject,java.lang.String> nameFunction,
org.eclipse.xtext.util.CancelIndicator ci) |
LocalUniqueNameContext(org.eclipse.emf.ecore.EObject container,
org.eclipse.xtext.util.CancelIndicator ci) |
LocalUniqueNameContext(org.eclipse.emf.ecore.EObject container,
java.util.function.Function<org.eclipse.emf.ecore.EObject,java.lang.String> nameFunction,
org.eclipse.xtext.util.CancelIndicator ci) |
LocalUniqueNameContext(java.lang.Iterable<T> objects,
java.util.function.Function<T,java.lang.String> nameFunction,
org.eclipse.xtext.util.CancelIndicator ci) |
LocalUniqueNameContext(java.util.List<? extends org.eclipse.emf.ecore.EObject> objects,
org.eclipse.xtext.util.CancelIndicator ci) |
| Modifier and Type | Method and Description |
|---|---|
org.eclipse.xtext.util.CancelIndicator |
cancelIndicator()
The cancel-indicator that shall be used.
|
java.lang.Iterable<IEObjectDescription> |
getExportedObjects() |
java.lang.Iterable<IEObjectDescription> |
getExportedObjects(org.eclipse.emf.ecore.EClass type,
QualifiedName name,
boolean ignoreCase) |
java.lang.Iterable<IEObjectDescription> |
getExportedObjectsByObject(org.eclipse.emf.ecore.EObject object) |
java.lang.Iterable<IEObjectDescription> |
getExportedObjectsByType(org.eclipse.emf.ecore.EClass type) |
java.util.List<IEObjectDescription> |
getObjectsToValidate()
Returns the objects that should be checked for uniqueness in the context of their
INamesAreUniqueValidationHelper.Context.getValidationScope(IEObjectDescription, EClass). |
ISelectable |
getValidationScope(IEObjectDescription description,
org.eclipse.emf.ecore.EClass clusterType)
Returns an
ISelectable that can be queried for elements with a given name to find duplicates. |
boolean |
isCaseSensitive(org.eclipse.emf.ecore.EObject candidate,
org.eclipse.emf.ecore.EClass clusterType)
Answers whether the names in the given cluster must be treated in a case
sensistive or insensitive manner.
|
boolean |
isEmpty()
Clients may want to check the selectable to skip its processing in case it is empty.
|
boolean |
isUnique()
Context implementations that do know from their construction if they will or won't
contain any duplicates, can override
INamesAreUniqueValidationHelper.Context.isUnique() to provide a more efficient means
to validate all candidates at once. |
public LocalUniqueNameContext(org.eclipse.emf.ecore.EObject container,
java.util.function.Function<org.eclipse.emf.ecore.EObject,java.lang.String> nameFunction,
org.eclipse.xtext.util.CancelIndicator ci)
public LocalUniqueNameContext(org.eclipse.emf.ecore.EObject container,
org.eclipse.xtext.util.CancelIndicator ci)
public LocalUniqueNameContext(org.eclipse.emf.ecore.EObject container,
boolean deep,
org.eclipse.xtext.util.CancelIndicator ci)
public LocalUniqueNameContext(org.eclipse.emf.ecore.EObject container,
boolean deep,
java.util.function.Function<org.eclipse.emf.ecore.EObject,java.lang.String> nameFunction,
org.eclipse.xtext.util.CancelIndicator ci)
public LocalUniqueNameContext(java.lang.Iterable<T> objects,
java.util.function.Function<T,java.lang.String> nameFunction,
org.eclipse.xtext.util.CancelIndicator ci)
public LocalUniqueNameContext(java.util.List<? extends org.eclipse.emf.ecore.EObject> objects,
org.eclipse.xtext.util.CancelIndicator ci)
public boolean isUnique()
INamesAreUniqueValidationHelper.ContextINamesAreUniqueValidationHelper.Context.isUnique() to provide a more efficient means
to validate all candidates at once.isUnique in interface INamesAreUniqueValidationHelper.Contextpublic final boolean isCaseSensitive(org.eclipse.emf.ecore.EObject candidate,
org.eclipse.emf.ecore.EClass clusterType)
INamesAreUniqueValidationHelper.ContextisCaseSensitive in interface INamesAreUniqueValidationHelper.ContextICaseInsensitivityHelperpublic ISelectable getValidationScope(IEObjectDescription description, org.eclipse.emf.ecore.EClass clusterType)
INamesAreUniqueValidationHelper.Context
Returns an ISelectable that can be queried for elements with a given name to find duplicates.
Depending on the type of objects that have to have unique names, different selectables may be returned. Some objects must be unique per project, others must be globally unique or only unique per file. This API allows to fine tune the scope of the validation.
getValidationScope in interface INamesAreUniqueValidationHelper.Contextdescription - the description of the validated object.clusterType - the root type of the validated type hierarchy.public java.util.List<IEObjectDescription> getObjectsToValidate()
INamesAreUniqueValidationHelper.ContextINamesAreUniqueValidationHelper.Context.getValidationScope(IEObjectDescription, EClass).getObjectsToValidate in interface INamesAreUniqueValidationHelper.Contextpublic org.eclipse.xtext.util.CancelIndicator cancelIndicator()
INamesAreUniqueValidationHelper.ContextcancelIndicator in interface INamesAreUniqueValidationHelper.Contextpublic java.lang.Iterable<IEObjectDescription> getExportedObjects()
getExportedObjects in interface ISelectablenull.public boolean isEmpty()
ISelectablefalse if it is too expensive to compute the actual result.isEmpty in interface ISelectabletrue if the selectable does not provide any descriptions.public java.lang.Iterable<IEObjectDescription> getExportedObjects(org.eclipse.emf.ecore.EClass type, QualifiedName name, boolean ignoreCase)
getExportedObjects in interface ISelectablenull.public java.lang.Iterable<IEObjectDescription> getExportedObjectsByObject(org.eclipse.emf.ecore.EObject object)
getExportedObjectsByObject in interface ISelectablenull.public java.lang.Iterable<IEObjectDescription> getExportedObjectsByType(org.eclipse.emf.ecore.EClass type)
getExportedObjectsByType in interface ISelectablenull.