List of usage examples for com.google.common.collect Table isEmpty
boolean isEmpty();
From source file:com.torodb.torod.db.postgresql.meta.routines.QueryRoutine.java
@Nonnull private static List<SplitDocument> translateDocuments(CollectionSchema colSchema, int expectedDocs, ResultSet rs) {/*from w w w. j a v a 2 s .c o m*/ try { List<SplitDocument> result = Lists.newArrayListWithCapacity(expectedDocs); Table<Integer, Integer, String> docInfo = HashBasedTable.create(); Integer lastDocId = null; Integer structureId = null; while (rs.next()) { int docId = rs.getInt(DOC_ID); if (lastDocId == null || lastDocId != docId) { if (lastDocId != null) { //if this is not the first iteration SplitDocument doc = processDocument(colSchema, lastDocId, structureId, docInfo); result.add(doc); } lastDocId = docId; structureId = null; assert docInfo.isEmpty(); } Object typeId = rs.getObject(TYPE_ID); Object index = rs.getObject(INDEX); String json = rs.getString(_JSON); if (typeId != null) { //subdocument assert typeId instanceof Integer; assert index == null || index instanceof Integer; assert json != null; if (index == null) { index = 0; } docInfo.put((Integer) typeId, (Integer) index, json); } else { //metainfo assert index != null; assert json == null; structureId = (Integer) index; } } if (lastDocId != null) { SplitDocument doc = processDocument(colSchema, lastDocId, structureId, docInfo); result.add(doc); } return result; } catch (SQLException ex) { //TODO: Change exception throw new RuntimeException(ex); } }
From source file:com.fredhopper.core.connector.index.generate.validator.List64AttributeValidator.java
@Override protected boolean isValidSize(final FhAttributeData attribute, final List<Violation> violations) { final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues(); if (values.isEmpty()) { rejectValue(attribute, violations, "The \"list64\" attribute \"" + attribute.getAttributeId() + "\" has no values assigned."); return false; }//from w w w .j a va 2s .co m if (values.rowKeySet().size() > MAX_SIZE) { rejectValue(attribute, violations, "The \"list64\" attribute \"" + attribute.getAttributeId() + "\" values total must not exceed 64."); return false; } return true; }
From source file:com.fredhopper.core.connector.index.generate.validator.Set64AttributeValidator.java
@Override protected boolean isValidSize(final FhAttributeData attribute, final List<Violation> violations) { final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues(); if (values.isEmpty()) { rejectValue(attribute, violations, "The \"set64\" attribute \"" + attribute.getAttributeId() + "\" has no values assigned."); return false; }/*from ww w . ja v a2s.c om*/ if (values.rowKeySet().size() > MAX_SIZE) { rejectValue(attribute, violations, "The \"set64\" attribute \"" + attribute.getAttributeId() + "\" values total must not exceed 64."); return false; } return true; }
From source file:com.fredhopper.core.connector.index.generate.validator.TextAttributeValidator.java
@Override protected boolean isValidSize(final FhAttributeData attribute, final List<Violation> violations) { final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues(); if (values.isEmpty() || values.rowKeySet().size() != 1) { rejectValue(attribute, violations, "The \"text\" attribute can only have one value."); return false; }/* w w w . j a va 2 s . co m*/ return true; }
From source file:com.fredhopper.core.connector.index.generate.validator.AssetAttributeValidator.java
@Override protected boolean isValidSize(final FhAttributeData attribute, final List<Violation> violations) { final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues(); if (values.isEmpty() || values.rowKeySet().size() != 1) { rejectValue(attribute, violations, "The \"asset\" attribute should cover one localized value."); return false; }//from w w w . j a va2 s. co m return true; }
From source file:com.fredhopper.core.connector.index.generate.validator.IntAttributeValidator.java
@Override protected boolean isValidSize(final FhAttributeData attribute, final List<Violation> violations) { final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues(); if (values.isEmpty() || values.rowKeySet().size() != 1) { rejectValue(attribute, violations, "The \"int\" attribute can only have one value."); return false; }/* w ww . jav a 2 s . c o m*/ return true; }
From source file:com.fredhopper.core.connector.index.generate.validator.ListAttributeValidator.java
@Override protected boolean isValidSize(final FhAttributeData attribute, final List<Violation> violations) { final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues(); if (values.isEmpty()) { rejectValue(attribute, violations, "The \"list\" attribute \"" + attribute.getAttributeId() + "\" has no values assigned."); return false; }/*from www .j a v a2s . co m*/ return true; }
From source file:com.fredhopper.core.connector.index.generate.validator.FloatAttributeValidator.java
@Override protected boolean isValidSize(final FhAttributeData attribute, final List<Violation> violations) { final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues(); if (values.isEmpty() || values.rowKeySet().size() != 1) { rejectValue(attribute, violations, "The \"float\" attribute can only have one value."); return false; }/*from w w w. j av a2 s.com*/ return true; }
From source file:com.fredhopper.core.connector.index.generate.validator.SetAttributeValidator.java
@Override protected boolean isValidSize(final FhAttributeData attribute, final List<Violation> violations) { final Table<Optional<String>, Optional<Locale>, String> values = attribute.getValues(); if (values.isEmpty()) { rejectValue(attribute, violations, "The \"set\" attribute \"" + attribute.getAttributeId() + "\" has no values assigned."); return false; }//from w w w . j ava 2s. co m return true; }
From source file:com.google.gerrit.server.mail.MergedSender.java
private String format(String type, Table<Account.Id, String, PatchSetApproval> approvals) { StringBuilder txt = new StringBuilder(); if (approvals.isEmpty()) { return ""; }//from w ww.ja v a 2 s .co m txt.append(type).append(":\n"); for (Account.Id id : approvals.rowKeySet()) { txt.append(" "); txt.append(getNameFor(id)); txt.append(": "); boolean first = true; for (LabelType lt : labelTypes.getLabelTypes()) { PatchSetApproval ca = approvals.get(id, lt.getName()); if (ca == null) { continue; } if (first) { first = false; } else { txt.append("; "); } LabelValue v = lt.getValue(ca); if (v != null) { txt.append(v.getText()); } else { txt.append(lt.getName()); txt.append('='); txt.append(LabelValue.formatValue(ca.getValue())); } } txt.append('\n'); } txt.append('\n'); return txt.toString(); }