/** Returns the key's name or {@code null} if it has an id instead. */ public String getName() { return getLeaf().getName(); }
private int comparePathElements(final PathElement here, final PathElement there) { final int result = here.getKind().compareTo(there.getKind()); if (result != 0) { return result; } else if (here.getNameOrId() == null && there.getNameOrId() == null) { return compareToWithIdentityHash(here, there); } else if (here.hasId()) { return there.hasId() ? Long.compare(here.getId(), there.getId()) : -1; } else { return there.hasId() ? 1 : here.getName().compareTo(there.getName()); } }
/** Returns the key's parent. */ @Override public Key getParent() { List<PathElement> ancestors = getAncestors(); if (ancestors.isEmpty()) { return null; } PathElement parent = ancestors.get(ancestors.size() - 1); Key.Builder keyBuilder; if (parent.hasName()) { keyBuilder = Key.newBuilder(getProjectId(), parent.getKind(), parent.getName()); } else { keyBuilder = Key.newBuilder(getProjectId(), parent.getKind(), parent.getId()); } String namespace = getNamespace(); if (namespace != null) { keyBuilder.setNamespace(namespace); } return keyBuilder.addAncestors(ancestors.subList(0, ancestors.size() - 1)).build(); }
/** Returns the key's name or {@code null} if it has an id instead. */ public String getName() { return getLeaf().getName(); }
private WorkflowId parseWorkflowId(Entity workflow) { final String componentId = workflow.getKey().getAncestors().get(0).getName(); final String id = workflow.getKey().getName(); return WorkflowId.create(componentId, id); }
/** Returns the key's parent. */ @Override public Key getParent() { List<PathElement> ancestors = getAncestors(); if (ancestors.isEmpty()) { return null; } PathElement parent = ancestors.get(ancestors.size() - 1); Key.Builder keyBuilder; if (parent.hasName()) { keyBuilder = Key.newBuilder(getProjectId(), parent.getKind(), parent.getName()); } else { keyBuilder = Key.newBuilder(getProjectId(), parent.getKind(), parent.getId()); } String namespace = getNamespace(); if (namespace != null) { keyBuilder.setNamespace(namespace); } return keyBuilder.addAncestors(ancestors.subList(0, ancestors.size() - 1)).build(); }