/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.polaris.persistence.nosql.coretypes;

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import org.apache.polaris.persistence.nosql.api.index.IndexContainer;
import org.apache.polaris.persistence.nosql.api.index.IndexKey;
import org.apache.polaris.persistence.nosql.api.obj.BaseCommitObj;
import org.apache.polaris.persistence.nosql.api.obj.ObjRef;

public interface ContainerObj extends BaseCommitObj {
  /** Holds the mapping of fully qualified names to object references. */
  IndexContainer<ObjRef> nameToObjRef();

  /**
   * Contains the mapping of {@linkplain ObjBase#stableId() stable IDs} to fully qualified names.
   *
   * <p>This index is meant as a temporary construct during the transition from numeric ID-based
   * parent-child relationships and references to using fully qualified names as the primary
   * identifier on all APIs (catalogs, catalog state, principals, etc.).
   */
  IndexContainer<IndexKey> stableIdToName();

  interface Builder<O extends ContainerObj, B extends ContainerObj.Builder<O, B>>
      extends BaseCommitObj.Builder<O, B> {
    @CanIgnoreReturnValue
    B from(ContainerObj container);

    @CanIgnoreReturnValue
    B nameToObjRef(IndexContainer<ObjRef> nameToObjRef);

    @CanIgnoreReturnValue
    B stableIdToName(IndexContainer<IndexKey> stableIdToName);
  }
}
