public boolean variantOf(TriplePattern pattern) {
Map<Node, Node> vmap = CollectionFactory.createHashedMap();
if ( ! variantOf(subject, pattern.subject, vmap) ) return false;
if ( ! variantOf(predicate, pattern.predicate, vmap) ) return false;
if (Functor.isFunctor(object) && Functor.isFunctor(pattern.object)) {
Functor functor = (Functor)object.getLiteralValue();
Functor pFunctor = (Functor)pattern.object.getLiteralValue();
if ( ! functor.getName().equals(pFunctor.getName()) ) return false;
Node[] args = functor.getArgs();
Node[] pargs = pFunctor.getArgs();
if ( args.length != pargs.length ) return false;
for (int i = 0; i < args.length; i++) {
if ( ! variantOf(args[i], pargs[i], vmap) ) return false;
}
return true;