@Override
public TargetAtom getTripleTargetAtom(ImmutableTerm subject, ImmutableTerm pred, ImmutableTerm object) {
DistinctVariableOnlyDataAtom projectionAtom = atomFactory.getDistinctTripleAtom(
(subject instanceof Variable) ? (Variable) subject : s,
(pred instanceof Variable) && (!pred.equals(subject)) ? (Variable) pred : p,
(object instanceof Variable) && (!object.equals(subject)) && (!object.equals(pred)) ? (Variable) object : o);
ImmutableList<ImmutableTerm> initialTerms = ImmutableList.of(subject, pred, object);
ImmutableSubstitution<ImmutableTerm> substitution = substitutionFactory.getSubstitution(
IntStream.range(0, 3)
.boxed()
.map(i -> Maps.immutableEntry(projectionAtom.getTerm(i), initialTerms.get(i)))
.filter(e -> !e.getKey().equals(e.getValue()))
.collect(ImmutableCollectors.toMap()));
return new TargetAtomImpl(projectionAtom, substitution);
}