private static int countRefPathsInObjectSpec(final ObjectSpecification o) { int count = 0; // there's probably some obnoxiously smarter way to do this if (o.getObjPath() != null && !o.getObjPath().isEmpty()) { count++; } if (o.getObjRefPath() != null && !o.getObjRefPath().isEmpty()) { count++; } if (o.getToObjPath() != null && !o.getToObjPath().isEmpty()) { count++; } if (o.getToObjRefPath() != null && !o.getToObjRefPath().isEmpty()) { count++; } if (longToBoolean(o.getFindReferencePath())) { count++; } return count; }
private static ObjectIdentifier buildObjectIdentifier( final ObjectSpecification o, ObjectIdentifier oi, final int objcount) { final SubsetSelection paths = getObjectPaths(o); final List<ObjectIdentifier> refchain; try { final RefChainResult res = processRefChains(o); if (res == null) { refchain = null; } else if (res.isToPath) { refchain = new LinkedList<>(); if (res.path.size() > 1) { refchain.addAll(res.path.subList(1, res.path.size())); } refchain.add(oi); oi = res.path.get(0); } else { refchain = res.path; } } catch (IllegalArgumentException e) { throw new IllegalArgumentException( "Error on ObjectSpecification #" + objcount + ": " + e.getLocalizedMessage(), e); } final boolean searchDAG = longToBoolean(o.getFindReferencePath()); if (paths == null && refchain == null && !searchDAG) { return oi; } else if (paths == null) { if (searchDAG) { return new ObjectIDWithRefPath(oi); } else { return new ObjectIDWithRefPath(oi, refchain); } } else { if (searchDAG) { return new ObjIDWithRefPathAndSubset(oi, paths); } else { return new ObjIDWithRefPathAndSubset(oi, refchain, paths); } } }