// SPDX-License-Identifier: Apache-2.0
import { InvalidResourceNameError } from '../errors/invalid-resource-name-error.js';
import { isDns1123Resource } from '../kube-validation.js';
export class ResourceName {
    name;
    constructor(type, name) {
        this.name = name;
        if (!this.isValid()) {
            throw new InvalidResourceNameError(name, type);
        }
    }
    /**
     * Returns true if the pod name is valid.  A Kubernetes pod name must be a valid RFC-1123 DNS label.
     *
     * @include DNS_1123_LABEL
     *
     * @returns true if the pod name is valid.
     * @throws InvalidResourceNameError if the pod name is invalid.
     */
    isValid() {
        return isDns1123Resource(this.name);
    }
    /**
     * Compares this instance with another PodName.
     * @param other The other PodName instance.
     * @returns true if both instances have the same name.
     */
    equals(other) {
        return other instanceof ResourceName && this.name === other.name;
    }
    /**
     * Allows implicit conversion to a string.
     * @returns The pod name as a string.
     */
    toString() {
        return this.name;
    }
    /**
     * Allows `PodName` to be used as a primitive string in operations.
     */
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    [Symbol.toPrimitive](_hint) {
        return this.name;
    }
    /**
     * Returns the primitive value of the object.
     */
    valueOf() {
        return this.name;
    }
}
//# sourceMappingURL=resource-name.js.map