@Nullable public <T> Entity getEntity(T id, AttributeType<T> rtype){ Attribute<T> iri = rtype.getAttribute(id); Thing inst = iri != null? iri.ownerInstances().findFirst().orElse(null) : null; return inst != null? inst.asEntity() : null; }
/** * Map an Thing to the equivalent Graql representation * @param thing thing to be mapped * @return Graql representation of given thing */ public static VarPattern map(Thing thing){ if(thing.isEntity()){ return map(thing.asEntity()); } else if(thing.isAttribute()){ return map(thing.asAttribute()); } else if(thing.isRelationship()){ return map(thing.asRelationship()); } else { throw CommonUtil.unreachableStatement("Unrecognised thing " + thing); } }