// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.managementgroups.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.management.ProxyResource;
import com.azure.resourcemanager.managementgroups.fluent.models.EntityHierarchyItemProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** The management group details for the hierarchy view. */
@Fluent
public final class EntityHierarchyItem extends ProxyResource {
    /*
     * The generic properties of a management group.
     */
    @JsonProperty(value = "properties")
    private EntityHierarchyItemProperties innerProperties;

    /** Creates an instance of EntityHierarchyItem class. */
    public EntityHierarchyItem() {
    }

    /**
     * Get the innerProperties property: The generic properties of a management group.
     *
     * @return the innerProperties value.
     */
    private EntityHierarchyItemProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the displayName property: The friendly name of the management group.
     *
     * @return the displayName value.
     */
    public String displayName() {
        return this.innerProperties() == null ? null : this.innerProperties().displayName();
    }

    /**
     * Set the displayName property: The friendly name of the management group.
     *
     * @param displayName the displayName value to set.
     * @return the EntityHierarchyItem object itself.
     */
    public EntityHierarchyItem withDisplayName(String displayName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new EntityHierarchyItemProperties();
        }
        this.innerProperties().withDisplayName(displayName);
        return this;
    }

    /**
     * Get the permissions property: The users specific permissions to this item.
     *
     * @return the permissions value.
     */
    public Permissions permissions() {
        return this.innerProperties() == null ? null : this.innerProperties().permissions();
    }

    /**
     * Set the permissions property: The users specific permissions to this item.
     *
     * @param permissions the permissions value to set.
     * @return the EntityHierarchyItem object itself.
     */
    public EntityHierarchyItem withPermissions(Permissions permissions) {
        if (this.innerProperties() == null) {
            this.innerProperties = new EntityHierarchyItemProperties();
        }
        this.innerProperties().withPermissions(permissions);
        return this;
    }

    /**
     * Get the children property: The list of children.
     *
     * @return the children value.
     */
    public List<EntityHierarchyItem> children() {
        return this.innerProperties() == null ? null : this.innerProperties().children();
    }

    /**
     * Set the children property: The list of children.
     *
     * @param children the children value to set.
     * @return the EntityHierarchyItem object itself.
     */
    public EntityHierarchyItem withChildren(List<EntityHierarchyItem> children) {
        if (this.innerProperties() == null) {
            this.innerProperties = new EntityHierarchyItemProperties();
        }
        this.innerProperties().withChildren(children);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (innerProperties() != null) {
            innerProperties().validate();
        }
    }
}
