/** * Finds the default node type for a child node with the given name. * * @param nameWithIndex child node name, possibly with an SNS index * @return default type, or {@code null} if not found */ @Nullable String getDefaultType(@NotNull String nameWithIndex) { String name = dropIndexFromName(nameWithIndex); boolean sns = !name.equals(nameWithIndex); for (NodeState type : types) { NodeState named = type .getChildNode(REP_NAMED_CHILD_NODE_DEFINITIONS) .getChildNode(name); NodeState residual = type .getChildNode(REP_RESIDUAL_CHILD_NODE_DEFINITIONS); for (ChildNodeEntry entry : concat( named.getChildNodeEntries(), residual.getChildNodeEntries())) { NodeState definition = entry.getNodeState(); String defaultType = definition.getName(JCR_DEFAULTPRIMARYTYPE); if (defaultType != null && snsMatch(sns, definition)) { return defaultType; } } } return null; }
/** * Finds the default node type for a child node with the given name. * * @param nameWithIndex child node name, possibly with an SNS index * @return default type, or {@code null} if not found */ @Nullable String getDefaultType(@NotNull String nameWithIndex) { String name = dropIndexFromName(nameWithIndex); boolean sns = !name.equals(nameWithIndex); for (NodeState type : types) { NodeState named = type .getChildNode(REP_NAMED_CHILD_NODE_DEFINITIONS) .getChildNode(name); NodeState residual = type .getChildNode(REP_RESIDUAL_CHILD_NODE_DEFINITIONS); for (ChildNodeEntry entry : concat( named.getChildNodeEntries(), residual.getChildNodeEntries())) { NodeState definition = entry.getNodeState(); String defaultType = definition.getName(JCR_DEFAULTPRIMARYTYPE); if (defaultType != null && snsMatch(sns, definition)) { return defaultType; } } } return null; }
/** * Finds the default node type for a child node with the given name. * * @param nameWithIndex child node name, possibly with an SNS index * @return default type, or {@code null} if not found */ @CheckForNull String getDefaultType(@Nonnull String nameWithIndex) { String name = dropIndexFromName(nameWithIndex); boolean sns = !name.equals(nameWithIndex); for (NodeState type : types) { NodeState named = type .getChildNode(REP_NAMED_CHILD_NODE_DEFINITIONS) .getChildNode(name); NodeState residual = type .getChildNode(REP_RESIDUAL_CHILD_NODE_DEFINITIONS); for (ChildNodeEntry entry : concat( named.getChildNodeEntries(), residual.getChildNodeEntries())) { NodeState definition = entry.getNodeState(); String defaultType = definition.getName(JCR_DEFAULTPRIMARYTYPE); if (defaultType != null && snsMatch(sns, definition)) { return defaultType; } } } return null; }