private Q addConstraint(String type, TitanPredicate rel, Object value) {
Preconditions.checkArgument(type!=null && StringUtils.isNotBlank(type) && rel!=null);
if (type.equals(ImplicitKey.ADJACENT_ID.getName())) {
Preconditions.checkArgument(rel == Cmp.EQUAL,"Only equality constraints are supported for %s",type);
Preconditions.checkArgument(value instanceof Number,"Expected valid vertex id: %s",value);
return adjacent(getVertex(((Number)value).longValue()));
} else if (type.equals(ImplicitKey.ID.getName())) {
Preconditions.checkArgument(value instanceof RelationIdentifier,"Expected valid relation id: %s",value);
return addConstraint(ImplicitKey.TITANID.getName(),rel,((RelationIdentifier)value).getRelationId());
}
if (constraints==NO_CONSTRAINTS) constraints = new ArrayList<PredicateCondition<String, TitanRelation>>(5);
constraints.add(new PredicateCondition<String, TitanRelation>(type, rel, value));
return getThis();
}