public Node createNode()

in Utils/azure-toolkit-ide-libs/azure-toolkit-ide-keyvault-lib/src/main/java/com/microsoft/azure/toolkit/ide/keyvault/KeyVaultNodeProvider.java [60:136]


    public Node<?> createNode(@Nonnull Object data, @Nullable Node<?> parent, @Nonnull Manager manager) {
        if (data instanceof AzureKeyVault) {
            final Function<AzureKeyVault, List<KeyVault>> function = azureKeyVault ->
                    azureKeyVault.list().stream().flatMap(m -> m.getKeyVaultModule().list().stream()).collect(Collectors.toList());
            return new AzServiceNode<>(az(AzureKeyVault.class))
                    .withIcon(ICON)
                    .withLabel(NAME)
                    .withActions(KeyVaultActionsContributor.SERVICE_ACTIONS)
                    .addChildren(function, (d, p) -> this.createNode(d, p, manager));
        } else if (data instanceof KeyVault) {
            return new AzResourceNode<>((KeyVault) data)
                    .addInlineAction(ResourceCommonActionsContributor.PIN)
                    .addChildren(KeyVault::getSubModules, (module, keyVaultNode) -> createNode(module, keyVaultNode, manager))
                    .withActions(KeyVaultActionsContributor.KEY_VAULT_ACTIONS);
        } else if (data instanceof CertificateModule) {
            return new AzModuleNode<>((CertificateModule) data)
                    .withIcon(AzureIcons.KeyVault.CERTIFICATES)
                    .withLabel("Certificates")
                    .addChildren(CertificateModule::list, (d, p) -> this.createNode(d, p, manager))
                    .withActions(KeyVaultActionsContributor.MODULE_ACTIONS);
        } else if (data instanceof Certificate) {
            final Function<Certificate, List<CertificateVersion>> function = certificate -> certificate.versions().list().stream()
                    .sorted(Comparator.comparing(CertificateVersion::isCurrentVersion).thenComparing(CertificateVersion::isEnabled).reversed())
                    .collect(Collectors.toList());
            return new AzResourceNode<>((Certificate) data)
                    .withDescription(key -> key.isEnabled() ? "enabled" : "disabled")
                    .addChildren(function, (d, p) -> this.createNode(d, p, manager))
                    .addInlineAction(ResourceCommonActionsContributor.PIN)
                    .withActions(KeyVaultActionsContributor.CERTIFICATE_ACTIONS);
        } else if (data instanceof CertificateVersion) {
            return new AzResourceNode<>((CertificateVersion) data)
                    .withDescription(KeyVaultNodeProvider::getCertificateVersionDescription)
                    .onDoubleClicked(ResourceCommonActionsContributor.OPEN_PORTAL_URL)
                    .withActions(KeyVaultActionsContributor.CERTIFICATE_VERSION_ACTIONS);
        } else if (data instanceof SecretModule) {
            return new AzModuleNode<>((SecretModule) data)
                    .withIcon(AzureIcons.KeyVault.SECRETS)
                    .withLabel("Secrets")
                    .addChildren(AbstractAzResourceModule::list, (d, p) -> this.createNode(d, p, manager))
                    .withActions(KeyVaultActionsContributor.MODULE_ACTIONS);
        } else if (data instanceof Secret) {
            final Function<Secret, List<SecretVersion>> function = secret -> secret.versions().list().stream()
                    .sorted(Comparator.comparing(SecretVersion::isCurrentVersion).thenComparing(SecretVersion::isEnabled).reversed())
                    .collect(Collectors.toList());
            return new AzResourceNode<>((Secret) data)
                    .withDescription(key -> key.isEnabled() ? "enabled" : "disabled")
                    .addChildren(function, (d, p) -> this.createNode(d, p, manager))
                    .addInlineAction(ResourceCommonActionsContributor.PIN)
                    .withActions(KeyVaultActionsContributor.SECRET_ACTIONS);
        } else if (data instanceof SecretVersion) {
            return new AzResourceNode<>((SecretVersion) data)
                    .withDescription(KeyVaultNodeProvider::getSecretVersionDescription)
                    .onDoubleClicked(ResourceCommonActionsContributor.OPEN_PORTAL_URL)
                    .withActions(KeyVaultActionsContributor.SECRET_VERSION_ACTIONS);
        } else if (data instanceof KeyModule) {
            return new AzModuleNode<>((KeyModule) data)
                    .withIcon(AzureIcons.KeyVault.KEYS)
                    .withLabel("Keys")
                    .addChildren(AbstractAzResourceModule::list, (d, p) -> this.createNode(d, p, manager))
                    .withActions(KeyVaultActionsContributor.MODULE_ACTIONS);
        } else if (data instanceof Key) {
            final Function<Key, List<KeyVersion>> function = key -> key.versions().list().stream()
                    .sorted(Comparator.comparing(KeyVersion::isCurrentVersion).thenComparing(KeyVersion::isEnabled).reversed())
                    .collect(Collectors.toList());
            return new AzResourceNode<>((Key) data)
                    .withDescription(key -> key.isEnabled() ? "enabled" : "disabled")
                    .addChildren(function, (d, p) -> this.createNode(d, p, manager))
                    .addInlineAction(ResourceCommonActionsContributor.PIN)
                    .withActions(KeyVaultActionsContributor.KEY_ACTIONS);
        } else if (data instanceof KeyVersion) {
            return new AzResourceNode<>((KeyVersion) data)
                    .withDescription(KeyVaultNodeProvider::getKeyVersionDescription)
                    .onDoubleClicked(ResourceCommonActionsContributor.OPEN_PORTAL_URL)
                    .withActions(KeyVaultActionsContributor.KEY_VERSION_ACTIONS);
        }
        return null;
    }