use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class BarCacheModel method toString.
@Override
public String toString() {
StringBundler sb = new StringBundler(27);
sb.append("{uuid=");
sb.append(uuid);
sb.append(", barId=");
sb.append(barId);
sb.append(", groupId=");
sb.append(groupId);
sb.append(", companyId=");
sb.append(companyId);
sb.append(", userId=");
sb.append(userId);
sb.append(", userName=");
sb.append(userName);
sb.append(", createDate=");
sb.append(createDate);
sb.append(", modifiedDate=");
sb.append(modifiedDate);
sb.append(", field1=");
sb.append(field1);
sb.append(", field2=");
sb.append(field2);
sb.append(", field3=");
sb.append(field3);
sb.append(", field4=");
sb.append(field4);
sb.append(", field5=");
sb.append(field5);
sb.append("}");
return sb.toString();
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class BarModelImpl method toXmlString.
@Override
public String toXmlString() {
Map<String, Function<Bar, Object>> attributeGetterFunctions = getAttributeGetterFunctions();
StringBundler sb = new StringBundler(5 * attributeGetterFunctions.size() + 4);
sb.append("<model><model-name>");
sb.append(getModelClassName());
sb.append("</model-name>");
for (Map.Entry<String, Function<Bar, Object>> entry : attributeGetterFunctions.entrySet()) {
String attributeName = entry.getKey();
Function<Bar, Object> attributeGetterFunction = entry.getValue();
sb.append("<column><column-name>");
sb.append(attributeName);
sb.append("</column-name><column-value><![CDATA[");
sb.append(attributeGetterFunction.apply((Bar) this));
sb.append("]]></column-value></column>");
}
sb.append("</model>");
return sb.toString();
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class BarModelImpl method toString.
@Override
public String toString() {
Map<String, Function<Bar, Object>> attributeGetterFunctions = getAttributeGetterFunctions();
StringBundler sb = new StringBundler(4 * attributeGetterFunctions.size() + 2);
sb.append("{");
for (Map.Entry<String, Function<Bar, Object>> entry : attributeGetterFunctions.entrySet()) {
String attributeName = entry.getKey();
Function<Bar, Object> attributeGetterFunction = entry.getValue();
sb.append(attributeName);
sb.append("=");
sb.append(attributeGetterFunction.apply((Bar) this));
sb.append(", ");
}
if (sb.index() > 1) {
sb.setIndex(sb.index() - 1);
}
sb.append("}");
return sb.toString();
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class BarPersistenceImpl method findByUuid_Last.
/**
* Returns the last bar in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the last matching bar
* @throws NoSuchBarException if a matching bar could not be found
*/
@Override
public Bar findByUuid_Last(String uuid, OrderByComparator<Bar> orderByComparator) throws NoSuchBarException {
Bar bar = fetchByUuid_Last(uuid, orderByComparator);
if (bar != null) {
return bar;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append("}");
throw new NoSuchBarException(msg.toString());
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class BarPersistenceImpl method fetchByUUID_G.
/**
* Returns the bar where uuid = ? and groupId = ? or returns <code>null</code> if it could not be found, optionally using the finder cache.
*
* @param uuid the uuid
* @param groupId the group ID
* @param useFinderCache whether to use the finder cache
* @return the matching bar, or <code>null</code> if a matching bar could not be found
*/
@Override
public Bar fetchByUUID_G(String uuid, long groupId, boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] { uuid, groupId };
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(_finderPathFetchByUUID_G, finderArgs, this);
}
if (result instanceof Bar) {
Bar bar = (Bar) result;
if (!Objects.equals(uuid, bar.getUuid()) || (groupId != bar.getGroupId())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_BAR_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_G_UUID_3);
} else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(groupId);
List<Bar> list = q.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(_finderPathFetchByUUID_G, finderArgs, list);
}
} else {
Bar bar = list.get(0);
result = bar;
cacheResult(bar);
}
} catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(_finderPathFetchByUUID_G, finderArgs);
}
throw processException(e);
} finally {
closeSession(session);
}
}
if (result instanceof List<?>) {
return null;
} else {
return (Bar) result;
}
}
Aggregations