com.liferay.asset.link.service.persistence.impl.AssetLinkModelArgumentsResolver Maven / Gradle / Ivy
/**
* SPDX-FileCopyrightText: (c) 2023 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.asset.link.service.persistence.impl;
import com.liferay.asset.link.model.AssetLinkTable;
import com.liferay.asset.link.model.impl.AssetLinkImpl;
import com.liferay.asset.link.model.impl.AssetLinkModelImpl;
import com.liferay.portal.kernel.dao.orm.ArgumentsResolver;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.model.BaseModel;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.osgi.service.component.annotations.Component;
/**
* The arguments resolver class for retrieving value from AssetLink.
*
* @author Brian Wing Shun Chan
* @generated
*/
@Component(
property = {
"class.name=com.liferay.asset.link.model.impl.AssetLinkImpl",
"table.name=AssetLink"
},
service = ArgumentsResolver.class
)
public class AssetLinkModelArgumentsResolver implements ArgumentsResolver {
@Override
public Object[] getArguments(
FinderPath finderPath, BaseModel> baseModel, boolean checkColumn,
boolean original) {
String[] columnNames = finderPath.getColumnNames();
if ((columnNames == null) || (columnNames.length == 0)) {
if (baseModel.isNew()) {
return new Object[0];
}
return null;
}
AssetLinkModelImpl assetLinkModelImpl = (AssetLinkModelImpl)baseModel;
long columnBitmask = assetLinkModelImpl.getColumnBitmask();
if (!checkColumn || (columnBitmask == 0)) {
return _getValue(assetLinkModelImpl, columnNames, original);
}
Long finderPathColumnBitmask = _finderPathColumnBitmasksCache.get(
finderPath);
if (finderPathColumnBitmask == null) {
finderPathColumnBitmask = 0L;
for (String columnName : columnNames) {
finderPathColumnBitmask |= assetLinkModelImpl.getColumnBitmask(
columnName);
}
if (finderPath.isBaseModelResult() &&
(AssetLinkPersistenceImpl.
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION ==
finderPath.getCacheName())) {
finderPathColumnBitmask |= _ORDER_BY_COLUMNS_BITMASK;
}
_finderPathColumnBitmasksCache.put(
finderPath, finderPathColumnBitmask);
}
if ((columnBitmask & finderPathColumnBitmask) != 0) {
return _getValue(assetLinkModelImpl, columnNames, original);
}
return null;
}
@Override
public String getClassName() {
return AssetLinkImpl.class.getName();
}
@Override
public String getTableName() {
return AssetLinkTable.INSTANCE.getTableName();
}
private static Object[] _getValue(
AssetLinkModelImpl assetLinkModelImpl, String[] columnNames,
boolean original) {
Object[] arguments = new Object[columnNames.length];
for (int i = 0; i < arguments.length; i++) {
String columnName = columnNames[i];
if (original) {
arguments[i] = assetLinkModelImpl.getColumnOriginalValue(
columnName);
}
else {
arguments[i] = assetLinkModelImpl.getColumnValue(columnName);
}
}
return arguments;
}
private static final Map _finderPathColumnBitmasksCache =
new ConcurrentHashMap<>();
private static final long _ORDER_BY_COLUMNS_BITMASK;
static {
long orderByColumnsBitmask = 0;
orderByColumnsBitmask |= AssetLinkModelImpl.getColumnBitmask("weight");
_ORDER_BY_COLUMNS_BITMASK = orderByColumnsBitmask;
}
}