org.eclipse.xtext.validation.CompositeEValidator Maven / Gradle / Ivy
/*******************************************************************************
* Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
*******************************************************************************/
package org.eclipse.xtext.validation;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.util.EObjectValidator;
import com.google.common.collect.Lists;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.name.Named;
/**
* @author Sven Efftinge - Initial contribution and API
*/
public class CompositeEValidator implements EValidator {
public static final String USE_EOBJECT_VALIDATOR = "org.eclipse.xtext.validation.CompositeEValidator.USE_EOBJECT_VALIDATOR";
private List contents;
private static final Logger logger = Logger.getLogger(CompositeEValidator.class);
@Inject(optional=true)
@Named(value=USE_EOBJECT_VALIDATOR)
private boolean useEObjectValidator = true;
@Inject
private Provider equalitySupportProvider;
public static class EValidatorEqualitySupport {
private EValidator delegate;
@Override
public boolean equals(Object obj) {
if (!(obj instanceof EValidatorEqualitySupport))
return false;
return ((EValidatorEqualitySupport) obj).getDelegate().getClass().equals(getDelegate().getClass());
}
@Override
public int hashCode() {
return getDelegate().getClass().getName().hashCode();
}
public void setDelegate(EValidator delegate) {
this.delegate = delegate;
}
public EValidator getDelegate() {
return delegate;
}
}
protected void initDefaults() {
if (isUseEObjectValidator()) {
this.addValidator(new EObjectValidator(){
@Override
public boolean validate_EveryProxyResolves(EObject eObject, DiagnosticChain diagnostics,
Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy