/** * For testing purpose. * @noreference This method is not intended to be referenced by clients. * @nooverride This method is not intended to be re-implemented or extended by clients. * @since 2.4 */ public CompositeEValidator getCopyAndClearContents() { CompositeEValidator result = new CompositeEValidator(); result.equalitySupportProvider = this.equalitySupportProvider; result.useEObjectValidator = this.useEObjectValidator; if (this.contents != null) { result.contents = Lists.newArrayList(this.contents); this.contents = null; } return result; } }
protected void initDefaults() { if (isUseEObjectValidator()) { this.addValidator(new EObjectValidator(){ @Override public boolean validate_EveryProxyResolves(EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) { // don't check, we have our own implementation, which creates nicer messages return true; } @Override public boolean validate_NoCircularContainment(EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) { // don't check return true; } }); } }
public void addValidator(EValidator validator) { if (this == validator) return; if (validator instanceof CompositeEValidator) { CompositeEValidator other = (CompositeEValidator) validator; for(int i = 0; i < other.getContents().size(); i++) addValidator(other.getContents().get(i).delegate); } else { EValidatorEqualitySupport equalitySupport = equalitySupportProvider.get(); equalitySupport.setDelegate(validator); if (!getContents().contains(equalitySupport)) this.getContents().add(equalitySupport); } }
public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) { boolean result = true; for (int i = 0; i < getContents().size(); i++) { EValidatorEqualitySupport val = getContents().get(i); try { result &= val.getDelegate().validate(eClass, eObject, diagnostics, context); } catch (Exception e) { logger.error("Error executing EValidator", e); diagnostics.add(createExceptionDiagnostic("Error executing EValidator", eClass, e)); } } return result; }
public static GlobalStateMemento makeCopyOfGlobalState() { GlobalStateMemento memento = new GlobalStateMemento(); memento.validatorReg = new HashMap<EPackage, Object>(EValidator.Registry.INSTANCE); for(Map.Entry<EPackage, Object> validatorEntry: memento.validatorReg.entrySet()) { Object existingValue = validatorEntry.getValue(); if (existingValue instanceof CompositeEValidator) { validatorEntry.setValue(((CompositeEValidator) existingValue).getCopyAndClearContents()); } } memento.epackageReg = new HashMap<String, Object>(EPackage.Registry.INSTANCE); memento.protocolToFactoryMap = new HashMap<String, Object>(Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap()); memento.extensionToFactoryMap = new HashMap<String, Object>(Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap()); memento.contentTypeIdentifierToFactoryMap = new HashMap<String, Object>(Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap()); memento.protocolToServiceProviderMap = new HashMap<String, Object>(IResourceServiceProvider.Registry.INSTANCE.getProtocolToFactoryMap()); memento.extensionToServiceProviderMap = new HashMap<String, Object>(IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap()); memento.contentTypeIdentifierToServiceProviderMap = new HashMap<String, Object>(IResourceServiceProvider.Registry.INSTANCE.getContentTypeToFactoryMap()); return memento; }
public List<EValidatorEqualitySupport> getContents() { if (contents == null) { contents = new ArrayList<EValidatorEqualitySupport>(4); initDefaults(); } return contents; }
public void register(EPackage ePackage, EValidator registerMe) { EValidator validator = getRegistry().getEValidator(ePackage); if (validator == null) { validator = compositeProvider.get(); } else if (!(validator instanceof CompositeEValidator)) { CompositeEValidator newValidator = compositeProvider.get(); newValidator.addValidator(validator); validator = newValidator; } ((CompositeEValidator) validator).addValidator(registerMe); getRegistry().put(ePackage, validator); }
public boolean validate(EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) { boolean result = true; for (int i = 0; i < getContents().size(); i++) { EValidatorEqualitySupport val = getContents().get(i); try { result &= val.getDelegate().validate(eObject, diagnostics, context); } catch (Exception e) { logger.error("Error executing EValidator", e); diagnostics.add(createExceptionDiagnostic("Error executing EValidator", eObject, e)); } } return result; }
public static GlobalStateMemento makeCopyOfGlobalState() { GlobalStateMemento memento = new GlobalStateMemento(); memento.validatorReg = new HashMap<EPackage, Object>(EValidator.Registry.INSTANCE); for(Map.Entry<EPackage, Object> validatorEntry: memento.validatorReg.entrySet()) { Object existingValue = validatorEntry.getValue(); if (existingValue instanceof CompositeEValidator) { validatorEntry.setValue(((CompositeEValidator) existingValue).getCopyAndClearContents()); } } memento.epackageReg = new HashMap<String, Object>(EPackage.Registry.INSTANCE); memento.protocolToFactoryMap = new HashMap<String, Object>(Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap()); memento.extensionToFactoryMap = new HashMap<String, Object>(Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap()); memento.contentTypeIdentifierToFactoryMap = new HashMap<String, Object>(Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap()); memento.protocolToServiceProviderMap = new HashMap<String, Object>(IResourceServiceProvider.Registry.INSTANCE.getProtocolToFactoryMap()); memento.extensionToServiceProviderMap = new HashMap<String, Object>(IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap()); memento.contentTypeIdentifierToServiceProviderMap = new HashMap<String, Object>(IResourceServiceProvider.Registry.INSTANCE.getContentTypeToFactoryMap()); return memento; }
public boolean validate(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) { boolean result = true; for (int i = 0; i < getContents().size(); i++) { EValidatorEqualitySupport val = getContents().get(i); try { result &= val.getDelegate().validate(eDataType, value, diagnostics, context); } catch (Exception e) { logger.error("Error executing EValidator", e); diagnostics.add(createExceptionDiagnostic("Error executing EValidator", eDataType, e)); } } return result; }