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

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

There is a newer version: 3.0.107
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.Table;

import java.util.Objects;

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

	@SuppressWarnings("unchecked")
	public static > Column getPrimaryKeyColumn(
		Table table) {

		for (Column column : table.getColumns()) {
			if (column.isPrimaryKey() &&
				!Objects.equals(column.getName(), "ctCollectionId") &&
				Long.class.isAssignableFrom(column.getJavaType())) {

				return (Column)column;
			}
		}

		return null;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy