// Copyright 2022 The Nomulus Authors. All Rights Reserved.
//
// Licensed 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 google.registry.persistence;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Entity;
import java.io.Serializable;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

/**
 * Annotation for {@link Entity} that can be saved as a foreign key in the form of a {@link VKey} in
 * another table.
 *
 * <p>A {@link AttributeConverter} named {@code VKeyConverter_[EntityClassSimpleName]} will be
 * automatically generated by {@code google.registry.processors.VKeyProcessor}, this class must be
 * manually added to {@code persistence.xml} in order for it to be picked up by Hibernate.
 */
@Target({ElementType.TYPE})
public @interface WithVKey {
  /** The type of the SQL primary ID of the entity that is saved in the {@link VKey} */
  Class<? extends Serializable> value();
}
