Java Code Examples for com.google.common.collect.Table#isEmpty()
The following examples show how to use
com.google.common.collect.Table#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BrokerMessageConverter.java From joyqueue with Apache License 2.0 | 5 votes |
public static Table<String, Short, FetchMessageData> convert(String app, Table<String, Short, FetchPartitionMessageAckData> topicMessageTable) { Table<String, Short, FetchMessageData> result = HashBasedTable.create(); if (topicMessageTable == null || topicMessageTable.isEmpty()) { return result; } for (Map.Entry<String, Map<Short, FetchPartitionMessageAckData>> topicEntry : topicMessageTable.rowMap().entrySet()) { String topic = topicEntry.getKey(); Map<Short, FetchPartitionMessageAckData> partitionMap = topicEntry.getValue(); for (Map.Entry<Short, FetchPartitionMessageAckData> partitionEntry : partitionMap.entrySet()) { result.put(topic, partitionEntry.getKey(), new FetchMessageData(convert(topic, app, partitionEntry.getValue().getMessages()), partitionEntry.getValue().getCode())); } } return result; }
Example 2
Source File: TableSerializer.java From jackson-datatypes-collections with Apache License 2.0 | 5 votes |
@Override public void serialize(final Table<?, ?, ?> value, final JsonGenerator gen, final SerializerProvider provider) throws IOException { gen.writeStartObject(value); if ( !value.isEmpty()) { serializeFields(value, gen, provider); } gen.writeEndObject(); }
Example 3
Source File: RedisCenterImpl.java From cachecloud with Apache License 2.0 | 5 votes |
private void fillAccumulationMap(Map<RedisConstant, Map<String, Object>> infoMap, Table<RedisConstant, String, Long> table) { if (table == null || table.isEmpty()) { return; } Map<String, Object> accMap = infoMap.get(RedisConstant.DIFF); if (accMap == null) { accMap = new LinkedHashMap<String, Object>(); infoMap.put(RedisConstant.DIFF, accMap); } for (RedisConstant constant : table.rowKeySet()) { Map<String, Long> rowMap = table.row(constant); accMap.putAll(rowMap); } }
Example 4
Source File: SameCodeResourceLoader.java From arcusplatform with Apache License 2.0 | 4 votes |
@Override public SameCodeRegistry parse(InputStream is) { LOGGER.debug("Parsing NWS SAME Code input data file"); /* * Create a guava table. These tables have two keys, each called a vertex. * This table will be indexed as follows stateCode, county, samecode * Conceptually it is the equivalent of Map<stateCode, Map<county, * sameCode>> * * Provides for easy lookup of SameCode objects by both keys * stateCode,county */ Table<String, String, SameCode> sameCodes; ImmutableTable.Builder<String, String, SameCode> sameCodeBuilder = new ImmutableTable.Builder<String, String, SameCode>(); // ListMultimap conceptually provides Map<stateCode, List<counties>> ListMultimap<String, String> sameCounties = ArrayListMultimap.create(); try (CSVReader reader = new CSVReader(new InputStreamReader(is), 0, new CSVParser())){ String[] nextLine; while ((nextLine = reader.readNext()) != null){ if (nextLine.length < 3) { // error in input file, skip continue; } String code = nextLine[0]; String county = nextLine[1]; /* * The NWS SAME code data file can contain whitespace around state * codes on load, strip this out */ String stateCode = nextLine[2].trim(); if (StringUtils.isEmpty(code) || StringUtils.isEmpty(county) || StringUtils.isEmpty(stateCode)) { LOGGER.warn( "Invalid NWS SAME Code Record, null value(s) found while parsing input date file for values Code:{} County:{} and State Code:{}", code, county, stateCode); continue; // skip } SameState sameState = sameStates.get(stateCode); if (sameState == null) { LOGGER.warn("Missing NWS SAME Code State Name mapping for NWS State Code: {}", stateCode); continue; // skip }else{ String state = sameStates.get(stateCode).getState(); sameCodeBuilder.put(stateCode, county, new SameCode(code, county, stateCode, state)); sameCounties.put(stateCode, county); } } }catch (Exception e){ LOGGER.warn("Error parsing NWS SAME Code input data file", e); throw new IllegalStateException(e); } sameCodes = sameCodeBuilder.build(); /* * Sort all lists before insertion into registry */ // For each state: sort counties by name sameCounties.keySet().stream().forEach(stateCode -> Collections.sort(sameCounties.get(stateCode))); // Sort SameStates before insertion into registry ( List<SameState> sameStateList = new ArrayList<SameState>(sameStates.values()); // Comparable sorts on stateCode Collections.sort(sameStateList); if (sameCodes.isEmpty()) { return null; } return new SameCodeRegistry(sameCodes, sameStateList, sameCounties); }
Example 5
Source File: TableSerializer.java From jackson-datatypes-collections with Apache License 2.0 | 4 votes |
@Override public boolean isEmpty(SerializerProvider provider, Table<?, ?, ?> table) { return table.isEmpty(); }