/*
(non-Javadoc)

@see
com.impetus.kundera.configure.schema.api.AbstractSchemaManager#validate
(java.util.List)
170947
@Override
    protected void validate(List<TableInfo> tableInfos)
    {

        if (!clusterManager.hasBucket(databaseName))
        {
            throw new SchemaGenerationException("Bucket [" + databaseName + "] does not exist.");
        }
    }
1039684
@Override
	public List<GigJavaProblem> validate(TypeDeclaration declaration,
			IType type, CompilationUnit unit, String file)
			throws JavaModelException {
		List<GigJavaProblem> problems = new ArrayList<GigJavaProblem>();
		int flags = type.getFlags();
		
		if (!Flags.isAbstract(flags)) {
			if (!Flags.isPublic(flags)) {
				GigJavaProblem problem = new GigJavaProblem(
						Severity.ERROR, "Concrete Component class must be public", file);
				ISourceRange range = type.getNameRange();
				int offset = range.getOffset();
				problem.setSourceStart(offset);
				problem.setSourceEnd(offset + range.getLength() - 1);
				problem.setSourceLineNumber(unit.getLineNumber(offset));
				problems.add(problem);
				return problems;
			}
		}
		
		return problems;
	}
945656
@Override
	public List<Diagnostic> validate(final List<Diagnostic> diags) {
		if (!isValid()) {
			List<Serializable> argList = getMessageArguments();
			Serializable[] args = argList.toArray(new Serializable[argList.size()]);

			diags.add(new DiagnosticImpl(Diagnostic.ERROR, input, getErrorMessage(), args));
		}

		return diags;
	}
1027718
@Override
    public void validate() {

        if (entityClass == null) {
            throw new IllegalArgumentException("testentity class cannot be null");
        }

        if (!entityClass.isAnnotationPresent(DeepEntity.class)) {
            throw new AnnotationTypeMismatchException(null, entityClass.getCanonicalName());
        }

        super.validate();

        /* let's validate fieldNames in @DeepField annotations */
        Field[] deepFields = AnnotationUtils.filterDeepFields(entityClass);

        Map<String, Cell> colDefs = super.columnDefinitions();

        /* colDefs is null if table does not exist. I.E. this configuration will be used as an output configuration
         object, and the output table is dynamically created */
        if (colDefs == null) {
            return;
        }

        for (Field field : deepFields) {
            String annotationFieldName = AnnotationUtils.deepFieldName(field);

            if (!colDefs.containsKey(annotationFieldName)) {
                throw new DeepNoSuchFieldException("Unknown column name \'" + annotationFieldName + "\' specified for" +
                        " field " + entityClass.getCanonicalName() + "#" + field.getName() + ". Please, " +
                        "make sure the field name you specify in @DeepField annotation matches _exactly_ the column " +
                        "name " +
                        "in the database");
            }
        }
    }
849038
@SuppressWarnings("unchecked")
    private void validateKey(int index) {
        final int size = (index + 1);
        if (null == this.keys) {
            // nothing has been created yet
            this.keys = (K[]) new Object[size];
        } else if (index >= this.keys.length) {
            // this row puts us beyond the current storage
            Object[] newKeys = new Object[size];
            System.arraycopy(this.keys, 0, newKeys, 0, this.keys.length);
            this.keys = (K[]) newKeys;
        }
    }
195933
private void validateKeyTypes(int[] keyFieldIndices) {
		final TypeInformation<?>[] types = getFieldTypes();
		for (int keyFieldIndex : keyFieldIndices) {
			final TypeInformation<?> type = types[keyFieldIndex];
			if (!TypeCheckUtils.isSimpleStringRepresentation(type)) {
				throw new ValidationException(
					"Only simple types that can be safely converted into a string representation " +
						"can be used as keys. But was: " + type);
			}
		}
	}
999767
public void validateConstraints(Entity entity) {
		for (String propertyName : requiredProperties) {
            Object value = entity.getProperty(propertyName);
			if (value == null || (value instanceof String && ((String) value).length() == 0)) {
				throw new RequiredFieldException("Required property '" + this.persistentClass.getSimpleName() + "." + propertyName + "' is not set");
			}
		}
	}
582050
public static void validateSchema(Bean bean) {
        validateId(bean);
        validatePropertyNames(bean);
        validateReferences(bean);
        validateProperties(bean);
        validatePropertyList(bean);
        validatePropertyReferences(bean);
        validatePropertyRefList(bean);
        validatePropertyRefMap(bean);
    }
130184
private void validate(List<ByteBuffer> variables) throws InvalidRequestException
    {
        // Ensure that exactly one key has been specified.
        if (keyValidator.size() < 1)
            throw new InvalidRequestException("You must specify a PRIMARY KEY");
        else if (keyValidator.size() > 1)
            throw new InvalidRequestException("You may only specify one PRIMARY KEY");

        AbstractType<?> comparator;

        try
        {
            cfProps.validate();
            comparator = cfProps.getComparator();
        }
        catch (ConfigurationException e)
        {
            throw new InvalidRequestException(e.toString());
        }
        catch (SyntaxException e)
        {
            throw new InvalidRequestException(e.toString());
        }

        for (Map.Entry<Term, String> column : columns.entrySet())
        {
            ByteBuffer name = column.getKey().getByteBuffer(comparator, variables);

            if (keyAlias != null && keyAlias.equals(name))
                throw new InvalidRequestException("Invalid column name: "
                                                  + column.getKey().getText()
                                                  + ", because it equals to the key_alias.");

        }
    }
1076801
@Override
    protected void validate(List<TableInfo> tableInfos)
    {
        for (TableInfo tableInfo : tableInfos)
        {
            try
            {
                if (tableAPI.getTable(tableInfo.getTableName()) == null)
                {
                    logger.error("No table found for " + tableInfo.getTableName());
                    throw new SchemaGenerationException("No table found for " + tableInfo.getTableName());
                }
            }
            catch (FaultException e)
            {
                logger.error("Error while getting table " + tableInfo.getTableName() + ". Caused By: ", e);
                throw new SchemaGenerationException(e, "Error while getting table " + tableInfo.getTableName()
                        + ". Caused By: ");
            }
        }
    }
348896
@Override
    public boolean validateEntity(Class clazz)
    {
        EntityValidatorAgainstCounterColumn entityValidatorAgainstSchema = new EntityValidatorAgainstCounterColumn();
        return entityValidatorAgainstSchema.validateEntity(clazz);
    }
1281879
@Override
    public boolean validate(Field f) throws RuleValidationException
    {

        boolean checkvalidation = true;
        for (Annotation annotate : f.getDeclaredAnnotations())
        {
            RelationType eruleType = getRuleType(annotate.annotationType().getSimpleName());

            if (eruleType != null)
            {

                switch (eruleType)
                {
                case MANY_TO_MANY:
                    checkvalidation = validateManyToMany(f, annotate);
                    break;
                case MANY_TO_ONE:
                    checkvalidation = validateManyToOne(f, annotate);
                    break;
                case ONE_TO_MANY:
                    checkvalidation = validateOneToMany(f, annotate);
                    break;
                case ONE_TO_ONE:
                    checkvalidation = validateOneToOne(f, annotate);
                    break;

                }

            }
        }

        return checkvalidation;
    }
367128
@Override
  public void validate(T arg) throws ValidationException {
    for (final Validator<T> validator : validators) {
      validator.validate(arg);
    }
  }
55221
@Override
    // TODO: reduce Cyclomatic complexity
    public final void validate(final Class<?> clazz)
    {

        if (classes.contains(clazz))
        {
            return;
        }

        if (log.isDebugEnabled())
            log.debug("Validating " + clazz.getName());

        // Is Entity?
//        if (clazz.isAnnotationPresent(MappedSuperclass.class))
//        {
//            throw new InvalidEntityDefinitionException("JPA operation over MappedSuperclass are not allowed" + clazz);
//        }
        
        
        // Is Entity?
        if (!clazz.isAnnotationPresent(Entity.class))
        {
            throw new InvalidEntityDefinitionException(clazz.getName() + " is not annotated with @Entity.");
        }

        
        // TODO:: add validation for MappedSuperClass.
        
//        // Must be annotated with @Table
//        if (!clazz.isAnnotationPresent(Table.class))
//        {
//            throw new InvalidEntityDefinitionException(clazz.getName() + " must be annotated with @Table.");
//        }

        // must have a default no-argument constructor
        try
        {
            clazz.getConstructor();
        }
        catch (NoSuchMethodException nsme)
        {
            throw new InvalidEntityDefinitionException(clazz.getName()
                    + " must have a default no-argument constructor.");
        }

        // Check for @Key and ensure that there is just 1 @Key field of String
        // type.
        List<Field> keys = new ArrayList<Field>();
        for (Field field : clazz.getDeclaredFields())
        {
            if (field.isAnnotationPresent(Id.class) && field.isAnnotationPresent(EmbeddedId.class))
            {
                throw new InvalidEntityDefinitionException(clazz.getName()
                        + " must have either @Id field or @EmbeddedId field");
            }

            if (field.isAnnotationPresent(Id.class))
            {
                keys.add(field);
                // validate @GeneratedValue annotation if given
                if (field.isAnnotationPresent(GeneratedValue.class))
                {
                    validateGeneratedValueAnnotation(clazz, field);
                }
            }
            else if (field.isAnnotationPresent(EmbeddedId.class))
            {
                keys.add(field);
            }
        }

        if (keys.size() < 0)
        {
            throw new InvalidEntityDefinitionException(clazz.getName() + " must have an @Id field.");
        }
        else if (keys.size() > 1)
        {
            throw new InvalidEntityDefinitionException(clazz.getName() + " can only have 1 @Id field.");
        }

        // save in cache

        classes.add(clazz);
    }
597223
private static void validateEntity(Entity entity) throws DbRuntimeException {
		if (null == entity) {
			throw new DbRuntimeException("Entity is null !");
		}
		if (StrUtil.isBlank(entity.getTableName())) {
			throw new DbRuntimeException("Entity`s table name is null !");
		}
		if (entity.isEmpty()) {
			throw new DbRuntimeException("No filed and value in this entity !");
		}
	}
1255696
@Override
    @SuppressWarnings("ConstantConditions")
    @Nonnull
    public <T> Set<ConstraintViolation<T>> validate(@Nonnull BeanIntrospection<T> introspection, @Nonnull T object, @Nullable Class<?>... groups) {
        if (introspection == null) {
            throw new ValidationException("Passed object [" + object + "] cannot be introspected. Please annotate with @Introspected");
        }
        @SuppressWarnings("unchecked")
        final Collection<? extends BeanProperty<Object, Object>> constrainedProperties =
                ((BeanIntrospection<Object>) introspection).getIndexedProperties(Constraint.class);
        @SuppressWarnings("unchecked")
        final Collection<BeanProperty<Object, Object>> cascadeProperties =
                ((BeanIntrospection<Object>) introspection).getIndexedProperties(Valid.class);

        if (CollectionUtils.isNotEmpty(constrainedProperties) || CollectionUtils.isNotEmpty(cascadeProperties)) {
            DefaultConstraintValidatorContext context = new DefaultConstraintValidatorContext(object, groups);
            Set<ConstraintViolation<T>> overallViolations = new HashSet<>(5);
            return doValidate(
                    object,
                    object,
                    constrainedProperties,
                    cascadeProperties,
                    context,
                    overallViolations
            );
        }
        return Collections.emptySet();
    }
1082446
@Override
    public void validate() throws OpsGenieClientValidationException {
        super.validate();
        if (name == null && id == null)
            throw OpsGenieClientValidationException.missingMultipleMandatoryProperty(OpsGenieClientConstants.API.NAME, OpsGenieClientConstants.API.ID);
    }