ExpandedNodeId { public Optional<ExpandedNodeId> relative(NamespaceTable namespaceTable) { if (isRelative()) { return Optional.of(this); } else { UShort namespaceIndex = namespaceTable.getIndex(namespaceUri); if (namespaceIndex != null) { ExpandedNodeId xni = new ExpandedNodeId( namespaceIndex, null, identifier, serverIndex ); return Optional.of(xni); } else { return Optional.empty(); } } } ExpandedNodeId(
        UShort namespaceIndex,
        String namespaceUri,
        UInteger identifier
    );  ExpandedNodeId(
        UShort namespaceIndex,
        String namespaceUri,
        UInteger identifier,
        UInteger serverIndex
    );  ExpandedNodeId(
        UShort namespaceIndex,
        String namespaceUri,
        String identifier
    );  ExpandedNodeId(
        UShort namespaceIndex,
        String namespaceUri,
        String identifier,
        UInteger serverIndex
    );  ExpandedNodeId(
        UShort namespaceIndex,
        String namespaceUri,
        ByteString identifier
    );  ExpandedNodeId(
        UShort namespaceIndex,
        String namespaceUri,
        ByteString identifier,
        UInteger serverIndex
    );  ExpandedNodeId(
        UShort namespaceIndex,
        String namespaceUri,
        UUID identifier
    );  ExpandedNodeId(
        UShort namespaceIndex,
        String namespaceUri,
        UUID identifier,
        UInteger serverIndex
    );  ExpandedNodeId(
        @Nonnull UShort namespaceIndex,
        @Nullable String namespaceUri,
        @Nullable Object identifier,
        @Nonnull UInteger serverIndex
    ); Object getIdentifier(); IdType getType(); UShort getNamespaceIndex(); @Nullable String getNamespaceUri(); UInteger getServerIndex(); boolean isAbsolute(); boolean isRelative(); boolean isLocal(); boolean isNull(); boolean isNotNull(); Optional<ExpandedNodeId> absolute(NamespaceTable namespaceTable); Optional<ExpandedNodeId> relative(NamespaceTable namespaceTable); ExpandedNodeId reindex(NamespaceTable namespaceTable, String namespaceUri); @Deprecated Optional<NodeId> local(NamespaceTable namespaceTable); @Deprecated NodeId localOrThrow(NamespaceTable namespaceTable); Optional<NodeId> toNodeId(NamespaceTable namespaceTable); NodeId toNodeIdOrThrow(NamespaceTable namespaceTable); @Override boolean equals(Object o); boolean equals(NodeId nodeId); boolean equals(NodeId nodeId, NamespaceTable namespaceTable); @Override int hashCode(); @Override String toString(); String toParseableString(); static ExpandedNodeId parse(String s); @Nullable static ExpandedNodeId parseOrNull(@Nonnull String s); static Optional<ExpandedNodeId> parseSafe(@Nonnull String s); static Builder newBuilder(); static final ExpandedNodeId NULL_VALUE; }
@Test public void relative() { ExpandedNodeId xni = new ExpandedNodeId(ushort(99), Namespaces.OPC_UA, "foo"); assertTrue(xni.isAbsolute()); ExpandedNodeId relative = xni.relative(new NamespaceTable()).orElseThrow(RuntimeException::new); assertTrue(relative.isRelative()); assertNull(relative.getNamespaceUri()); assertEquals(ushort(0), relative.getNamespaceIndex()); }