Check if the concept is of the given type and has a property that matches the given parameter.

@throws GraqlQueryException if the concept does not satisfy the parameter
481966
private <S extends Concept, T> void validateParam(
            Concept concept, BuilderParam<T> param, Class<S> conceptType, Function<S, T> getter) {

        if (has(param)) {
            T value = use(param);

            boolean isInstance = conceptType.isInstance(concept);

            if (!isInstance || !Objects.equals(getter.apply(conceptType.cast(concept)), value)) {
                throw GraqlQueryException.insertPropertyOnExistingConcept(param.name(), value, concept);
            }
        }
    }
592386
private boolean isValidConcept(final String concept, final Double score) {
    return !StringUtils.isBlank(concept)
           || score != null;
  }
1202112
@Override
    public <T> TypedQuery<X> setParameter(Parameter<T> arg0, T arg1)
    {
        query.setParameter(arg0, arg1);
        return this;
    }
799552
private void validate(Concept concept) {
        validateParam(concept, TYPE, Thing.class, Thing::type);
        validateParam(concept, SUPER_CONCEPT, SchemaConcept.class, SchemaConcept::sup);
        validateParam(concept, LABEL, SchemaConcept.class, SchemaConcept::label);
        validateParam(concept, ID, Concept.class, Concept::id);
        validateParam(concept, VALUE, Attribute.class, Attribute::value);
        validateParam(concept, DATA_TYPE, AttributeType.class, AttributeType::dataType);
        validateParam(concept, WHEN, Rule.class, Rule::when);
        validateParam(concept, THEN, Rule.class, Rule::then);
    }
929511
private <T> TypedQuery<T> onTypedQuery(Class<T> paramClass, Query q)
    {
        if (paramClass.equals(((QueryImpl) q).getKunderaQuery().getEntityClass()) || paramClass.equals(Object.class))
        {
            return new KunderaTypedQuery<T>(q);
        }

        throw new IllegalArgumentException("Mismatch in expected return type. Expected:" + paramClass
                + " But actual class is:" + ((QueryImpl) q).getKunderaQuery().getEntityClass());
    }
1189102
@SuppressWarnings("unchecked")
    @Override
    public Set<JsonEntityBean> search(String entityType, String searchTerm) {

        Set<JsonEntityBean> results = new HashSet<>();

        EntityEnum entityEnum = EntityEnum.getEntityEnum(entityType);
        if (entityEnum == null) {
            throw new IllegalArgumentException(
                    String.format("Parameter entityType has an unknown value of [%s]", entityType));
        }

        EntityIdentifier[] identifiers;

        Class identifierType;

        // if the entity type is a group, use the group service's findGroup method
        // to locate it
        if (entityEnum.isGroup()) {
            identifiers =
                    GroupService.searchForGroups(
                            searchTerm,
                            GroupService.SearchMethod.CONTAINS_CI,
                            entityEnum.getClazz());
            identifierType = IEntityGroup.class;
        }

        // otherwise use the getGroupMember method
        else {
            identifiers =
                    GroupService.searchForEntities(
                            searchTerm,
                            GroupService.SearchMethod.CONTAINS_CI,
                            entityEnum.getClazz());
            identifierType = entityEnum.getClazz();
        }

        for (int i = 0; i < identifiers.length; i++) {
            if (identifiers[i].getType().equals(identifierType)) {
                IGroupMember entity = GroupService.getGroupMember(identifiers[i]);
                if (entity != null) {
                    JsonEntityBean jsonBean = getEntity(entity);
                    results.add(jsonBean);
                } else {
                    log.warn("Grouper member entity of " + identifiers[i].getKey() + " is null.");
                }
            }
        }

        return results;
    }
12593
@Override
	public final SolrQuery doConstructSolrQuery(SolrDataQuery query, @Nullable Class<?> domainType) {

		Assert.notNull(query, "Cannot construct solrQuery from null value.");
		Assert.notNull(query.getCriteria(), "Query has to have a criteria.");

		SolrQuery solrQuery = new SolrQuery();
		solrQuery.setParam(CommonParams.Q, getQueryString(query, domainType));

		if (query instanceof Query) {
			processQueryOptions(solrQuery, (Query) query, domainType);
		}

		if (query instanceof FacetQuery) {
			processFacetOptions(solrQuery, (FacetQuery) query, domainType);
		}

		if (query instanceof HighlightQuery) {
			processHighlightOptions(solrQuery, (HighlightQuery) query, domainType);
		}

		return solrQuery;
	}
647189
private boolean hasOperationOfType(SQLiteDatabaseSchema schema, MethodSpec.Builder methodBuilder, JQLType jqlType) {
		boolean hasOperation = false;
		for (SQLiteDaoDefinition daoDefinition : schema.getCollection()) {

			if (daoDefinition.getElement().getAnnotation(BindContentProviderPath.class) == null)
				continue;

			for (SQLiteModelMethod daoMethod : daoDefinition.getCollection()) {
				if (daoMethod.jql.operationType != jqlType) {
					continue;
				}
				if (!daoMethod.hasAnnotation(BindContentProviderEntry.class)) {
					continue;
				}

				hasOperation = true;
				// methodBuilder.addJavadoc("method $L.$L\n",
				// daoDefinition.getName(), daoMethod.getName());
			}
		}
		return hasOperation;
	}
223655
@Override
	public boolean matches(Object entity) {
		T t = property.get(entity);
		
		for (T value : values) {
			if (t.compareTo(value) == 0) {
				return true;
			}
		}
		
		return false;
	}
1367715
@Override
    public boolean hasStatement(Resource subject, URI predicate, Value object, boolean includeInferred, Resource... contexts) throws RepositoryException {
        if(!this.isOpen()){throw new RepositoryException("Connection is closed.");}
        String queryString = null;
        if(contexts == null) {
            queryString="ASK { GRAPH ?ctx { ?s ?p ?o } filter (?ctx = (IRI(\""+DEFAULT_GRAPH_URI+"\")))}";
        }else if (contexts.length == 0) {
            queryString = SOMETHING;
        }
        else {
            StringBuilder sb= new StringBuilder();
            sb.append("ASK { GRAPH ?ctx { ?s ?p ?o } filter (?ctx = (");
                boolean first = true;
                for (Resource context : contexts) {
                    if (first) {
                        first = !first;
                    }
                    else {
                        sb.append(",");
                    }
                    if (context == null) {
                        sb.append("IRI(\""+DEFAULT_GRAPH_URI+"\")");
                    } else {
                        sb.append("IRI(\"" + context.toString() + "\")");
                    }
                }
                sb.append(") ) }");
            queryString = sb.toString();
        }
        try {
            logger.debug(queryString);
            MarkLogicBooleanQuery query = prepareBooleanQuery(queryString); // baseuri ?

            setBindings(query, subject, predicate, object, contexts);
            return query.evaluate();
        }
        catch (MalformedQueryException e) {
            throw new RepositoryException(e);
        }
        catch (QueryEvaluationException e) {
            throw new RepositoryException(e);
        }
    }
181658
public void validate(Query<? extends Entity> query, EntityType entityType) {
    query.getRules().forEach(queryRule -> validateQueryRule(queryRule, entityType));
  }
130590
public static void checkTypeConsistency(Schema schema,
                                          PartitionStrategy strategy,
                                          String fieldName, Object... values) {
    Schema fieldSchema = fieldSchema(schema, strategy, fieldName);

    for (Object value : values) {
      // SpecificData#validate checks consistency for generic, reflect,
      // and specific models.
      Preconditions.checkArgument(
          SpecificData.get().validate(fieldSchema, value),
          "Value '%s' of type '%s' inconsistent with field schema %s.",
          value, value.getClass(), fieldSchema);
    }
  }
272857
public boolean matches(String path, MatchingStrategy matchingStrategy) {
    return path!=null && matchingStrategy.matches(clause, path);
  }
200766
private Stream<ConceptSetMeasure> runComputeDegree(GraqlCompute.Centrality query) {
        Set<Label> targetTypeLabels;

        // Check if ofType is valid before returning emptyMap
        if (query.of().isEmpty()) {
            targetTypeLabels = scopeTypeLabels(query);
        } else {
            targetTypeLabels = query.of().stream()
                    .flatMap(t -> {
                        Label typeLabel = Label.of(t);
                        Type type = tx.getSchemaConcept(typeLabel);
                        if (type == null) throw GraqlQueryException.labelNotFound(typeLabel);
                        return type.subs();
                    })
                    .map(SchemaConcept::label)
                    .collect(toSet());
        }

        Set<Label> scopeTypeLabels = Sets.union(scopeTypeLabels(query), targetTypeLabels);

        if (!scopeContainsInstance(query)) {
            return Stream.empty();
        }

        Set<LabelId> scopeTypeLabelIDs = convertLabelsToIds(scopeTypeLabels);
        Set<LabelId> targetTypeLabelIDs = convertLabelsToIds(targetTypeLabels);

        ComputerResult computerResult = compute(new DegreeVertexProgram(targetTypeLabelIDs),
                                                new DegreeDistributionMapReduce(targetTypeLabelIDs, DegreeVertexProgram.DEGREE),
                                                scopeTypeLabelIDs);

        Map<Long, Set<ConceptId>> centralityMap = computerResult.memory().get(DegreeDistributionMapReduce.class.getName());

        return centralityMap.entrySet().stream()
                .map(centrality -> new ConceptSetMeasure(centrality.getValue(), centrality.getKey()));
    }
882885
protected final String checkArguments(Properties args, RequestType type) {
    // Why the following lines duplicate lines from Request#92 - handling query?
    // reset all arguments
    for (Argument arg: _arguments)
      arg.reset();
    // return query if in query mode
    if (type == RequestType.query)
      return buildQuery(args,type);

    /*
    // Check that for each actual input argument from the user, there is some
    // request argument that this method is expecting.
    //*/
    if (H2O.OPT_ARGS.check_rest_params && !(this instanceof GridSearch) && !(this instanceof HTTP500)) {
      Enumeration en = args.propertyNames();
      while (en.hasMoreElements()) {
        boolean found = false;
        String key = (String) en.nextElement();
        for (Argument arg: _arguments) {
          if (arg._name.equals(key)) {
            found = true;
            break;
          }
        }
        if (!found) {
          return jsonError("Request specifies the argument '"+key+"' but it is not a valid parameter for this query " + this.getClass().getName()).toString();
        }
      }
    }

    // check the arguments now
    for (Argument arg: _arguments) {
      if (!arg.disabled()) {
        try {
          arg.check(RequestQueries.this, args.getProperty(arg._name,""));
          queryArgumentValueSet(arg, args);
        } catch( IllegalArgumentException e ) {
          if (type == RequestType.json)
            return jsonError("Argument '"+arg._name+"' error: "+e.getMessage()).toString();
          else
            return buildQuery(args,type);
        }
      }
    }
    return null;
  }
541090
@Override
    public int getSqlType(String paramName) {
        if (!hasValue(paramName)) {
            return TYPE_UNKNOWN;
        }
        Object value = getValue(paramName);
        return StatementCreatorUtils.javaTypeToSqlParameterType(value.getClass());
    }
484794
private boolean evalClass(QueryImpl query,
                              QueryAtomGroupImpl group,
                              QueryResultImpl result,
                              QueryBindingImpl binding, QueryAtom atom) throws QueryEngineException {
        QueryArgument clsArg = atom.getArguments().get(0);
        if (!clsArg.isVar()) {
            return false;
        }
        BoundChecking boundChecking;
        // Need to check this but I think that if the variable is not bound then there's no need to recheck solutions
        Set<OWLClass> candidates = getClasses();
        return bindAndEvalClassCandidates(query, group, result, binding, clsArg, candidates, BoundChecking.DO_NOT_CHECK_BOUND);
    }