All Downloads are FREE. Search and download functionalities are using the official Maven repository.

is.codion.framework.model.DetailModelLink Maven / Gradle / Ivy

/*
 * This file is part of Codion.
 *
 * Codion is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Codion is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Codion.  If not, see .
 *
 * Copyright (c) 2022 - 2024, Björn Darri Sigurðsson.
 */
package is.codion.framework.model;

import is.codion.common.state.State;
import is.codion.framework.domain.entity.Entity;

import java.util.Collection;
import java.util.Map;

/**
 * Represents a link between a master and detail model.
 * @param  the {@link EntityModel} type
 * @param  the {@link EntityEditModel} type
 * @param  the {@link EntityTableModel} type
 */
public interface DetailModelLink, E extends EntityEditModel, T extends EntityTableModel> {

	/**
	 * @return the detail model
	 */
	M detailModel();

	/**
	 * Controls the active status of this link. Active detail model links update and filter
	 * the detail model according to the entity/entities selected in the master model.
	 * @return the state controlling the active status of this detail model link
	 */
	State active();

	/**
	 * Called when the selection changes in the master model
	 * @param selectedEntities the selected master entities
	 */
	default void onSelection(Collection selectedEntities) {}

	/**
	 * Called when a insert is performed in the master model, regardless of entity type.
	 * @param insertedEntities the inserted entities
	 */
	default void onInsert(Collection insertedEntities) {}

	/**
	 * Called when an update is performed in the master model, regardless of entity type.
	 * @param updatedEntities the updated entities, mapped to their original primary keys
	 */
	default void onUpdate(Map updatedEntities) {}

	/**
	 * Called when delete is performed in the master model, regardless of entity type.
	 * @param deletedEntities the deleted entities
	 */
	default void onDelete(Collection deletedEntities) {}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy