Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Datahub project Datahub HasDomains Mixin

From Leeroopedia
Revision as of 14:42, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Datahub_project_Datahub_HasDomains_Mixin.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Java_SDK, Metadata_Management
Last Updated 2026-02-10 00:00 GMT

Overview

Description

HasDomains is a mixin interface in the DataHub Java SDK V2 that provides domain assignment operations for entities. Entities implementing this interface can be assigned to DataHub domains for organizational governance. The interface supports setting a single domain, removing specific domains, clearing all domains, and retrieving domain assignments.

Mutation methods such as removeDomain() and clearDomains() are annotated with @RequiresMutable and enforce that the entity is not in a read-only state.

The interface uses the self-bounded generic pattern (T extends Entity & HasDomains<T>) for fluent API chaining.

Usage

Entity classes implement this interface to gain domain management capabilities. The setDomain() method replaces all existing domains with a single domain, while removeDomain() removes a specific one. Read operations (getDomain() and getDomains()) use lazy aspect loading.

Code Reference

Source Location

metadata-integration/java/datahub-client/src/main/java/datahub/client/v2/entity/HasDomains.java

Signature

public interface HasDomains<T extends Entity & HasDomains<T>> {

    @Nonnull
    default T setDomain(@Nonnull String domainUrn)

    @Nonnull
    default T setDomain(@Nonnull Urn domain)

    @Nonnull
    default T removeDomain(@Nonnull String domainUrn)

    @RequiresMutable
    @Nonnull
    default T removeDomain(@Nonnull Urn domain)

    @RequiresMutable
    @Nonnull
    default T clearDomains()

    @Nullable
    default Urn getDomain()

    @Nullable
    default List<Urn> getDomains()
}

Import

import datahub.client.v2.entity.HasDomains;

I/O Contract

Inputs

Method Parameter Type Description
setDomain domainUrn String URN string of the domain to assign
setDomain domain Urn URN object of the domain to assign
removeDomain domainUrn String URN string of the domain to remove
removeDomain domain Urn URN object of the domain to remove

Outputs

Method Return Type Description
setDomain T The entity itself for fluent chaining
removeDomain T The entity itself for fluent chaining
clearDomains T The entity itself for fluent chaining
getDomain Urn (nullable) The first domain URN, or null if none present
getDomains List<Urn> (nullable) All domain URNs, or null if none present

Exceptions:

  • InvalidUrnException - thrown if a string URN cannot be parsed
  • ReadOnlyEntityException - thrown by @RequiresMutable methods on read-only entities

Usage Examples

Dataset dataset = Dataset.builder()
    .platform("snowflake")
    .name("my_table")
    .build();

// Set a domain
dataset.setDomain("urn:li:domain:engineering");

// Read the domain back
Urn domain = dataset.getDomain();

// Remove a domain (requires mutable entity)
dataset.removeDomain("urn:li:domain:engineering");

// Clear all domains
dataset.clearDomains();

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment