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

com.liferay.change.tracking.internal.reference.TableJoinHolder Maven / Gradle / Ivy

There is a newer version: 3.0.108
Show newest version
/**
 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */

package com.liferay.change.tracking.internal.reference;

import com.liferay.petra.sql.dsl.Column;
import com.liferay.petra.sql.dsl.expression.Predicate;
import com.liferay.petra.sql.dsl.query.FromStep;
import com.liferay.petra.sql.dsl.query.JoinStep;
import com.liferay.petra.sql.dsl.query.WhereStep;
import com.liferay.petra.string.StringBundler;

import java.util.function.Function;

/**
 * @author Preston Crary
 */
public class TableJoinHolder {

	public static TableJoinHolder reverse(TableJoinHolder tableJoinHolder) {
		return new TableJoinHolder(
			tableJoinHolder.getParentPKColumn(),
			tableJoinHolder.getJoinFunction(),
			tableJoinHolder.getMissingRequirementWherePredicate(),
			tableJoinHolder.getMissingRequirementWhereStep(),
			tableJoinHolder.getChildPKColumn(), !tableJoinHolder.isReversed());
	}

	public TableJoinHolder(
		Column childPKColumn,
		Function joinFunction,
		Predicate missingRequirementWherePredicate,
		WhereStep missingRequirementWhereStep, Column parentPKColumn) {

		this(
			childPKColumn, joinFunction, missingRequirementWherePredicate,
			missingRequirementWhereStep, parentPKColumn, false);
	}

	public Column getChildPKColumn() {
		return _childPKColumn;
	}

	public Function getJoinFunction() {
		return _joinFunction;
	}

	public Predicate getMissingRequirementWherePredicate() {
		return _missingRequirementWherePredicate;
	}

	public WhereStep getMissingRequirementWhereStep() {
		return _missingRequirementWhereStep;
	}

	public Column getParentPKColumn() {
		return _parentPKColumn;
	}

	public boolean isReversed() {
		return _reversed;
	}

	@Override
	public String toString() {
		return StringBundler.concat(
			"{childPKColumn=", _childPKColumn, ", joinFunction=", _joinFunction,
			", missingParentWhereStep", _missingRequirementWhereStep,
			", _missingRequirementWherePredicate",
			_missingRequirementWherePredicate, ", parentPKColumn=",
			_parentPKColumn, ", reversed=", _reversed, "}");
	}

	private TableJoinHolder(
		Column childPKColumn,
		Function joinFunction,
		Predicate missingRequirementWherePredicate,
		WhereStep missingRequirementWhereStep, Column parentPKColumn,
		boolean reversed) {

		_childPKColumn = childPKColumn;
		_joinFunction = joinFunction;
		_missingRequirementWherePredicate = missingRequirementWherePredicate;
		_missingRequirementWhereStep = missingRequirementWhereStep;
		_parentPKColumn = parentPKColumn;
		_reversed = reversed;
	}

	private final Column _childPKColumn;
	private final Function _joinFunction;
	private final Predicate _missingRequirementWherePredicate;
	private final WhereStep _missingRequirementWhereStep;
	private final Column _parentPKColumn;
	private final boolean _reversed;

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy