Search in sources :

Example 1 with EValidatorRegistryImpl

use of org.eclipse.emf.ecore.impl.EValidatorRegistryImpl in project rest-modeling-framework by commercetools.

the class RamlValidationSetup method setupCustom.

/**
 * Registers validators.
 */
static Diagnostician setupCustom(List<RamlValidator> customValidators) {
    final EValidator.Registry registry = new EValidatorRegistryImpl();
    final List<EValidator> eValidators = customValidators.stream().map(ramlValidator -> (EValidator) ramlValidator).collect(Collectors.toList());
    registry.put(TypesPackage.eINSTANCE, new TypesValidator());
    registry.put(ModulesPackage.eINSTANCE, new ModulesValidator());
    registry.put(ResourcesPackage.eINSTANCE, new ResourcesValidator());
    registry.put(ResponsesPackage.eINSTANCE, new ResponsesValidator());
    final RamlObjectValidator ramlObjectValidator = new RamlObjectValidator();
    for (final EPackage ePackage : PACKAGES) {
        final CompositeValidator compositeValidator = new CompositeValidator();
        compositeValidator.add(ramlObjectValidator);
        final EValidator validator = registry.getEValidator(ePackage);
        if (validator != null) {
            compositeValidator.add(validator);
        }
        if (eValidators.size() > 0) {
            compositeValidator.addAll(eValidators);
        }
        registry.put(ePackage, compositeValidator);
    }
    return new Diagnostician(registry);
}
Also used : java.util(java.util) EValidatorRegistryImpl(org.eclipse.emf.ecore.impl.EValidatorRegistryImpl) ResponsesPackage(io.vrap.rmf.raml.model.responses.ResponsesPackage) ValuesPackage(io.vrap.rmf.raml.model.values.ValuesPackage) ModulesPackage(io.vrap.rmf.raml.model.modules.ModulesPackage) Collectors(java.util.stream.Collectors) EPackage(org.eclipse.emf.ecore.EPackage) EValidator(org.eclipse.emf.ecore.EValidator) Diagnostician(org.eclipse.emf.ecore.util.Diagnostician) Lists(com.google.common.collect.Lists) SecurityPackage(io.vrap.rmf.raml.model.security.SecurityPackage) ElementsPackage(io.vrap.rmf.raml.model.elements.ElementsPackage) ResourcesPackage(io.vrap.rmf.raml.model.resources.ResourcesPackage) TypesPackage(io.vrap.rmf.raml.model.types.TypesPackage) EPackage(org.eclipse.emf.ecore.EPackage) Diagnostician(org.eclipse.emf.ecore.util.Diagnostician) EValidator(org.eclipse.emf.ecore.EValidator) EValidatorRegistryImpl(org.eclipse.emf.ecore.impl.EValidatorRegistryImpl)

Example 2 with EValidatorRegistryImpl

use of org.eclipse.emf.ecore.impl.EValidatorRegistryImpl in project rest-modeling-framework by commercetools.

the class RamlValidationSetup method setupCustomOnly.

static Diagnostician setupCustomOnly(List<RamlValidator> customValidators) {
    final EValidator.Registry registry = new EValidatorRegistryImpl();
    final List<EValidator> eValidators = customValidators.stream().map(ramlValidator -> (EValidator) ramlValidator).collect(Collectors.toList());
    for (final EPackage ePackage : PACKAGES) {
        final CompositeValidator compositeValidator = new CompositeValidator();
        final EValidator validator = registry.getEValidator(ePackage);
        if (validator != null) {
            compositeValidator.add(validator);
        }
        if (eValidators.size() > 0) {
            compositeValidator.addAll(eValidators);
        }
        registry.put(ePackage, compositeValidator);
    }
    return new Diagnostician(registry);
}
Also used : java.util(java.util) EValidatorRegistryImpl(org.eclipse.emf.ecore.impl.EValidatorRegistryImpl) ResponsesPackage(io.vrap.rmf.raml.model.responses.ResponsesPackage) ValuesPackage(io.vrap.rmf.raml.model.values.ValuesPackage) ModulesPackage(io.vrap.rmf.raml.model.modules.ModulesPackage) Collectors(java.util.stream.Collectors) EPackage(org.eclipse.emf.ecore.EPackage) EValidator(org.eclipse.emf.ecore.EValidator) Diagnostician(org.eclipse.emf.ecore.util.Diagnostician) Lists(com.google.common.collect.Lists) SecurityPackage(io.vrap.rmf.raml.model.security.SecurityPackage) ElementsPackage(io.vrap.rmf.raml.model.elements.ElementsPackage) ResourcesPackage(io.vrap.rmf.raml.model.resources.ResourcesPackage) TypesPackage(io.vrap.rmf.raml.model.types.TypesPackage) Diagnostician(org.eclipse.emf.ecore.util.Diagnostician) EValidator(org.eclipse.emf.ecore.EValidator) EValidatorRegistryImpl(org.eclipse.emf.ecore.impl.EValidatorRegistryImpl) EPackage(org.eclipse.emf.ecore.EPackage)

Example 3 with EValidatorRegistryImpl

use of org.eclipse.emf.ecore.impl.EValidatorRegistryImpl in project sirius-components by eclipse-sirius.

the class EMFConfiguration method getEValidatorRegistry.

@Bean
public EValidator.Registry getEValidatorRegistry() {
    Registry eValidatorRegistry = new EValidatorRegistryImpl(EValidator.Registry.INSTANCE);
    eValidatorRegistry.put(DomainPackage.eINSTANCE, new DomainValidator());
    eValidatorRegistry.put(ViewPackage.eINSTANCE, new DiagramDescriptionValidator());
    return eValidatorRegistry;
}
Also used : DomainValidator(org.eclipse.sirius.components.emf.domain.DomainValidator) Registry(org.eclipse.emf.ecore.EValidator.Registry) LabelFeatureProviderRegistry(org.eclipse.sirius.components.emf.services.LabelFeatureProviderRegistry) EValidatorRegistryImpl(org.eclipse.emf.ecore.impl.EValidatorRegistryImpl) DiagramDescriptionValidator(org.eclipse.sirius.components.emf.view.diagram.DiagramDescriptionValidator) Bean(org.springframework.context.annotation.Bean)

Example 4 with EValidatorRegistryImpl

use of org.eclipse.emf.ecore.impl.EValidatorRegistryImpl in project xtext-extras by eclipse.

the class AbstractTypeProviderTest method setUp.

@Before
public void setUp() throws Exception {
    EValidator.Registry registry = new EValidatorRegistryImpl(EValidator.Registry.INSTANCE);
    registry.put(TypesPackage.eINSTANCE, new EObjectValidator());
    diagnostician = new Diagnostician(registry);
}
Also used : Diagnostician(org.eclipse.emf.ecore.util.Diagnostician) EObjectValidator(org.eclipse.emf.ecore.util.EObjectValidator) EValidator(org.eclipse.emf.ecore.EValidator) EValidatorRegistryImpl(org.eclipse.emf.ecore.impl.EValidatorRegistryImpl) Before(org.junit.Before)

Example 5 with EValidatorRegistryImpl

use of org.eclipse.emf.ecore.impl.EValidatorRegistryImpl in project xtext-eclipse by eclipse.

the class AbstractTypeProviderTest method setUp.

@Before
public void setUp() throws Exception {
    EValidator.Registry registry = new EValidatorRegistryImpl(EValidator.Registry.INSTANCE);
    registry.put(TypesPackage.eINSTANCE, new EObjectValidator());
    diagnostician = new Diagnostician(registry);
}
Also used : Diagnostician(org.eclipse.emf.ecore.util.Diagnostician) EObjectValidator(org.eclipse.emf.ecore.util.EObjectValidator) EValidator(org.eclipse.emf.ecore.EValidator) EValidatorRegistryImpl(org.eclipse.emf.ecore.impl.EValidatorRegistryImpl) Before(org.junit.Before)

Aggregations

EValidatorRegistryImpl (org.eclipse.emf.ecore.impl.EValidatorRegistryImpl)5 EValidator (org.eclipse.emf.ecore.EValidator)4 Diagnostician (org.eclipse.emf.ecore.util.Diagnostician)4 Lists (com.google.common.collect.Lists)2 ElementsPackage (io.vrap.rmf.raml.model.elements.ElementsPackage)2 ModulesPackage (io.vrap.rmf.raml.model.modules.ModulesPackage)2 ResourcesPackage (io.vrap.rmf.raml.model.resources.ResourcesPackage)2 ResponsesPackage (io.vrap.rmf.raml.model.responses.ResponsesPackage)2 SecurityPackage (io.vrap.rmf.raml.model.security.SecurityPackage)2 TypesPackage (io.vrap.rmf.raml.model.types.TypesPackage)2 ValuesPackage (io.vrap.rmf.raml.model.values.ValuesPackage)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 EPackage (org.eclipse.emf.ecore.EPackage)2 EObjectValidator (org.eclipse.emf.ecore.util.EObjectValidator)2 Before (org.junit.Before)2 Registry (org.eclipse.emf.ecore.EValidator.Registry)1 DomainValidator (org.eclipse.sirius.components.emf.domain.DomainValidator)1 LabelFeatureProviderRegistry (org.eclipse.sirius.components.emf.services.LabelFeatureProviderRegistry)1 DiagramDescriptionValidator (org.eclipse.sirius.components.emf.view.diagram.DiagramDescriptionValidator)1