本文整理汇总了Java中com.google.common.collect.Table.get方法的典型用法代码示例。如果您正苦于以下问题:Java Table.get方法的具体用法?Java Table.get怎么用?Java Table.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Table
的用法示例。
在下文中一共展示了Table.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: groupByProfile
import com.google.common.collect.Table; //导入方法依赖的package包/类
/**
* 根据Profile分组,同名配置,根据Profile的优先级覆盖
*
* @param configItemList
* @param profileIdList
* @return
*/
private List<BuildConfigItem> groupByProfile(List<BuildConfigItem> configItemList, List<Integer> profileIdList) {
List<BuildConfigItem> filteredConfigItemList = new ArrayList<>();
Table<String, Integer, List<BuildConfigItem>> configItemTable = getConfigItemTable(configItemList);
for (String itemName : configItemTable.rowKeySet()) {
for (int profileId : profileIdList) {
List<BuildConfigItem> itemList = configItemTable.get(itemName, profileId);
if (itemList != null && !itemList.isEmpty()) {
filteredConfigItemList.addAll(itemList);
break;
}
}
}
return filteredConfigItemList;
}
示例2: getConfigItemTable
import com.google.common.collect.Table; //导入方法依赖的package包/类
/**
* 将配置项构造成一个二维表,[配置名称, Profile ID, 配置项]
*
* @param configItemList
* @return
*/
private Table<String, Integer, List<BuildConfigItem>> getConfigItemTable(List<BuildConfigItem> configItemList) {
Table<String, Integer, List<BuildConfigItem>> configItemTable = HashBasedTable.create();
List<BuildConfigItem> listByNameAndProfile = null;
for (BuildConfigItem configItem : configItemList) {
listByNameAndProfile = configItemTable.get(configItem.getConfigName(), configItem.getProfileId());
if (listByNameAndProfile == null) {
listByNameAndProfile = new ArrayList<>();
configItemTable.put(configItem.getConfigName(), configItem.getProfileId(), listByNameAndProfile);
}
listByNameAndProfile.add(configItem);
}
return configItemTable;
}
示例3: MediaTypeClassifierImpl
import com.google.common.collect.Table; //导入方法依赖的package包/类
MediaTypeClassifierImpl(Iterable<? extends MediaType> mts) {
Table<String, String, Set<MediaType>> typeTable =
HashBasedTable.<String, String, Set<MediaType>>create();
for (MediaType mt : mts) {
String type = mt.type();
String subtype = mt.subtype();
Set<MediaType> typeSet = typeTable.get(type, subtype);
if (typeSet == null) {
typeSet = Sets.newLinkedHashSet();
typeTable.put(type, subtype, typeSet);
}
typeSet.add(mt);
}
ImmutableTable.Builder<String, String, ImmutableSet<MediaType>> b =
ImmutableTable.builder();
for (Table.Cell<String, String, Set<MediaType>> cell
: typeTable.cellSet()) {
b.put(cell.getRowKey(), cell.getColumnKey(), ImmutableSet.copyOf(cell.getValue()));
}
this.types = b.build();
}
示例4: main
import com.google.common.collect.Table; //导入方法依赖的package包/类
public static void main(String[] args) {
String[] names = {"Bob", "Alice", "Andy", "Carol", "Ben"};
// Table of names
Table<Character, Integer, String> table = HashBasedTable.create();
// First letter is a row key, length is a column key
for (String name : names) {
table.put(name.charAt(0), name.length(), name);
}
// Value corresponding to the given row and column keys
table.get('A', 5); // -> Alice
table.get('B', 3); // -> Ben
// Set of column keys that have one or more values in the table
table.columnKeySet(); // -> [4, 5, 3]
// View of all mappings that have the given row key
table.row('A'); // -> {4=Andy, 5=Alice}
}
示例5: combineStrandJunctionsMaps
import com.google.common.collect.Table; //导入方法依赖的package包/类
/**
* Combine junctions from both strands. Used for Sashimi plot.
* Note: Flanking depth arrays are not combined.
*/
private List<SpliceJunctionFeature> combineStrandJunctionsMaps() {
// Start with all + junctions
Table<Integer, Integer, SpliceJunctionFeature> combinedStartEndJunctionsMap = HashBasedTable.create(posStartEndJunctionsMap);
// Merge in - junctions
for (Table.Cell<Integer, Integer, SpliceJunctionFeature> negJunctionCell : negStartEndJunctionsMap.cellSet()) {
int junctionStart = negJunctionCell.getRowKey();
int junctionEnd = negJunctionCell.getColumnKey();
SpliceJunctionFeature negFeat = negJunctionCell.getValue();
SpliceJunctionFeature junction = combinedStartEndJunctionsMap.get(junctionStart, junctionEnd);
if (junction == null) {
// No existing (+) junction here, just add the (-) one\
combinedStartEndJunctionsMap.put(junctionStart, junctionEnd, negFeat);
} else {
int newJunctionDepth = junction.getJunctionDepth() + negFeat.getJunctionDepth();
junction.setJunctionDepth(newJunctionDepth);
}
}
return new ArrayList<SpliceJunctionFeature>(combinedStartEndJunctionsMap.values());
}
示例6: BT
import com.google.common.collect.Table; //导入方法依赖的package包/类
/**
* Returns a community of nodes find in the
* overlapping matrix.
* @param m Table
* @param Clicks cliques
* @param q queue
* @param n int
* @return A community of nodes.
*/
private Community BT(Table<Integer,Integer,Integer> m, ArrayList<Set<Node>> Clicks, Queue<Integer> q, int n) {
Community c = new Community();
while (!(q.isEmpty())) {
Integer p = q.poll();
if (m.contains(p,p) && m.get(p,p) == 1) {
for (Node nn : Clicks.get(p)) c.addNode(nn);
m.put(p,p,0);
for (Integer i : m.row(p).keySet()) {
if (m.get(p, i) == 1) {
q.add( i);
m.put(p,i,0);
}
}
}
}
return c;
}
示例7: pickUtilization
import com.google.common.collect.Table; //导入方法依赖的package包/类
private static int pickUtilization(Table<Integer, String, AtomicInteger> u, int year,
String category) {
AtomicInteger value = u.get(year, category);
if (value == null) {
return 0;
} else {
return value.get();
}
}
示例8: initData
import com.google.common.collect.Table; //导入方法依赖的package包/类
public void initData(SparseMatrix dataMatrix) throws LibrecException {
Table<Integer, Integer, Double> dataTable = dataMatrix.getDataTable();
BiMap<String, Integer> userIds = dataModel.getUserMappingData();
BiMap<String, Integer> itemIds = dataModel.getItemMappingData();
SparseMatrix dateTimeDataSet = (SparseMatrix) dataModel.getDatetimeDataSet();
Table<Integer, Integer, Double> dateTimeTable = dateTimeDataSet.getDataTable();
for (Map.Entry<String, Integer> userId : userIds.entrySet()) {
for (Map.Entry<String, Integer> itemId : itemIds.entrySet()) {
Object scValue = dataTable.get(userId.getValue(), itemId.getValue());
Object dtValue = dateTimeTable.get(userId.getValue(), itemId.getValue());
if (scValue != null && dtValue != null) {
Long user_id = Long.parseLong(userId.getKey());
Long movie_id = Long.parseLong(itemId.getKey());
Double score = (Double)scValue;
Double datetime = (Double)dtValue;
Rating rating = new Rating(user_id, movie_id, score);
User user = User.findUser(user_id);
if (user == null) continue;
MovieEx movie = (MovieEx) MovieEx.findMovie(movie_id);
if (movie == null) continue;
try {
user.addMovie(movie, score, datetime);
movie.addUser(user, score, datetime);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
throw new LibrecException("load rating set error");
}
//rating.save();
Rating.allRatings.add(rating);
}
}
}
}
示例9: formatValues
import com.google.common.collect.Table; //导入方法依赖的package包/类
private static Map<String, Object> formatValues(Calendar time, Table<Calendar, String, Object> tableNO2) {
Map<String,Object> values = new HashMap<>();
for(String column : tableNO2.columnKeySet()) {
if (tableNO2.contains(time,column)) {
Object value = tableNO2.get(time,column);
values.put(column,value);
}
}
return values;
}
示例10: tableToCsv
import com.google.common.collect.Table; //导入方法依赖的package包/类
/**
* Converts Guava table to a CSV table
*
* @param table table
* @param csvFormat CSV format
* @param missingValuePlaceholder print if a value is missing (empty string by default)
* @param <T> object type (string)
* @return table
* @throws IOException exception
*/
public static <T> String tableToCsv(Table<String, String, T> table, CSVFormat csvFormat,
String missingValuePlaceholder)
throws IOException
{
StringWriter sw = new StringWriter();
CSVPrinter printer = new CSVPrinter(sw, csvFormat);
List<String> firstRow = new ArrayList<>();
firstRow.add(" ");
firstRow.addAll(table.columnKeySet());
printer.printRecord(firstRow);
for (String rowKey : table.rowKeySet()) {
printer.print(rowKey);
for (String columnKey : table.columnKeySet()) {
T value = table.get(rowKey, columnKey);
if (value == null) {
printer.print(missingValuePlaceholder);
}
else {
printer.print(value);
}
}
printer.println();
}
printer.close();
return sw.toString();
}
示例11: testGetNonLocalizedAttribute
import com.google.common.collect.Table; //导入方法依赖的package包/类
@Test
public void testGetNonLocalizedAttribute()
{
final ProductModel product = new ProductModel();
product.setCode("productCode");
when(sanitizeIdStrategy.sanitizeId(product.getCode())).thenReturn(product.getCode());
final MetaAttributeData metaAttribute = new MetaAttributeData();
metaAttribute.setBaseType(FhAttributeBaseType.TEXT);
metaAttribute.setAttributeId("url");
when(urlResolver.resolve(product)).thenReturn("/product/url/p/productCode");
final Collection<FhAttributeData> attributeDatas = productUrlProvider.getAttribute(product, metaAttribute, null);
assertNotNull(attributeDatas);
assertEquals(1, attributeDatas.size());
final FhAttributeData attributeData = attributeDatas.iterator().next();
assertEquals("productCode", attributeData.getItemId());
assertEquals("url", attributeData.getAttributeId());
assertEquals(FhAttributeBaseType.TEXT, attributeData.getBaseType());
final Table<Optional<String>, Optional<Locale>, String> values = attributeData.getValues();
assertNotNull(values);
assertEquals(1, values.size());
final String urlValue = values.get(Optional.empty(), Optional.empty());
assertEquals("/product/url/p/productCode", urlValue);
}
示例12: testGetLocalizedAttribute
import com.google.common.collect.Table; //导入方法依赖的package包/类
@Test
public void testGetLocalizedAttribute()
{
final ProductModel product = new ProductModel();
product.setCode("productCode");
when(sanitizeIdStrategy.sanitizeId(product.getCode())).thenReturn(product.getCode());
final MetaAttributeData metaAttribute = new MetaAttributeData();
metaAttribute.setBaseType(FhAttributeBaseType.SET);
metaAttribute.setAttributeId("url");
when(urlResolver.resolve(product)).thenReturn("/product/url-EN/p/productCode");
final Object value1 = "/product/url-EN/p/productCode";
final Collection<Locale> locales = Arrays.asList(Locale.ENGLISH);
when(sanitizeIdStrategy.sanitizeIdWithNumber(value1.toString())).thenReturn("_product_url_en_p_productcode");
final Collection<FhAttributeData> attributeDatas = productUrlProvider.getAttribute(product, metaAttribute, locales);
assertNotNull(attributeDatas);
assertEquals(1, attributeDatas.size());
final FhAttributeData attributeData = attributeDatas.iterator().next();
assertEquals("productCode", attributeData.getItemId());
assertEquals("url", attributeData.getAttributeId());
assertEquals(FhAttributeBaseType.SET, attributeData.getBaseType());
verify(i18nService).setCurrentLocale(Locale.ENGLISH);
final Table<Optional<String>, Optional<Locale>, String> values = attributeData.getValues();
assertNotNull(values);
assertEquals(1, values.size());
final String urlValueEN = values.get(Optional.of("_product_url_en_p_productcode"), Optional.of(Locale.ENGLISH));
assertEquals("/product/url-EN/p/productCode", urlValueEN);
}
示例13: testGetNonLocalizedAttribute
import com.google.common.collect.Table; //导入方法依赖的package包/类
@Test
public void testGetNonLocalizedAttribute()
{
final ProductModel product = new ProductModel();
product.setCode("productCode");
final ComposedTypeModel composedType = new ComposedTypeModel();
final MetaAttributeData metaAttribute = new MetaAttributeData();
metaAttribute.setBaseType(FhAttributeBaseType.FLOAT);
metaAttribute.setAttributeId("price");
metaAttribute.setQualifier("price");
when(typeService.getComposedTypeForClass(product.getClass())).thenReturn(composedType);
when(Boolean.valueOf(typeService.hasAttribute(composedType, "price"))).thenReturn(Boolean.TRUE);
when(modelService.getAttributeValue(product, "price")).thenReturn(BigDecimal.valueOf(12));
final Collection<FhAttributeData> attributeDatas = simpleAttributeProvider.getAttribute(product, metaAttribute, null);
assertNotNull(attributeDatas);
assertEquals(1, attributeDatas.size());
final FhAttributeData attributeData = attributeDatas.iterator().next();
assertEquals("productCode", attributeData.getItemId());
assertEquals("price", attributeData.getAttributeId());
assertEquals(FhAttributeBaseType.FLOAT, attributeData.getBaseType());
final Table<Optional<String>, Optional<Locale>, String> values = attributeData.getValues();
assertNotNull(values);
assertEquals(1, values.size());
final String priceValue = values.get(Optional.empty(), Optional.empty());
assertEquals("12", priceValue);
}
示例14: testLocalizedAssetAttribute
import com.google.common.collect.Table; //导入方法依赖的package包/类
/**
* Test method for
* {@link com.fredhopper.connector.index.provider.SimpleAttributeProvider#getAttribute(de.hybris.platform.core.model.product.ProductModel, com.fredhopper.model.export.data.MetaAttributeModel)}
* .
*/
@Test
public void testLocalizedAssetAttribute()
{
final ProductModel product = new ProductModel();
product.setCode("productCode");
final ComposedTypeModel composedType = new ComposedTypeModel();
final MetaAttributeData metaAttribute = new MetaAttributeData();
metaAttribute.setBaseType(FhAttributeBaseType.ASSET);
metaAttribute.setAttributeId("description");
metaAttribute.setQualifier("description");
when(typeService.getComposedTypeForClass(product.getClass())).thenReturn(composedType);
when(Boolean.valueOf(typeService.hasAttribute(composedType, "description"))).thenReturn(Boolean.TRUE);
final Collection<Locale> locales = Arrays.asList(Locale.US);
when(modelService.getAttributeValue(product, "description")).thenReturn("HUUUGE");
final Collection<FhAttributeData> attributeDatas = simpleAttributeProvider.getAttribute(product, metaAttribute, locales);
verify(i18nService, atLeastOnce()).setCurrentLocale(Locale.US);
assertNotNull(attributeDatas);
assertEquals(1, attributeDatas.size());
final FhAttributeData attributeData = attributeDatas.iterator().next();
assertEquals("productCode", attributeData.getItemId());
assertEquals("description", attributeData.getAttributeId());
assertEquals(FhAttributeBaseType.ASSET, attributeData.getBaseType());
final Table<Optional<String>, Optional<Locale>, String> values = attributeData.getValues();
assertNotNull(values);
assertEquals(1, values.size());
final String description = values.get(Optional.empty(), Optional.of(Locale.US));
assertEquals("HUUUGE", description);
}
示例15: testGetMultiValueAttribute
import com.google.common.collect.Table; //导入方法依赖的package包/类
@Test
public void testGetMultiValueAttribute()
{
final ProductModel product = new ProductModel();
product.setCode("productCode");
final ComposedTypeModel composedType = new ComposedTypeModel();
final MetaAttributeData metaAttribute = new MetaAttributeData();
metaAttribute.setBaseType(FhAttributeBaseType.SET);
metaAttribute.setAttributeId("sizes");
metaAttribute.setQualifier("sizes");
when(typeService.getComposedTypeForClass(product.getClass())).thenReturn(composedType);
when(Boolean.valueOf(typeService.hasAttribute(composedType, "sizes"))).thenReturn(Boolean.TRUE);
final Collection<String> sizeList = Arrays.asList("S", "M", "L");
when(modelService.getAttributeValue(product, "sizes")).thenReturn(sizeList);
final Collection<FhAttributeData> attributeDatas = simpleAttributeProvider.getAttribute(product, metaAttribute, null);
assertNotNull(attributeDatas);
assertEquals(1, attributeDatas.size());
final FhAttributeData attributeData = attributeDatas.iterator().next();
assertEquals("productCode", attributeData.getItemId());
assertEquals("sizes", attributeData.getAttributeId());
assertEquals(FhAttributeBaseType.SET, attributeData.getBaseType());
final Table<Optional<String>, Optional<Locale>, String> values = attributeData.getValues();
assertNotNull(values);
assertEquals(3, values.size());
final String sizeS = values.get(Optional.of("S"), Optional.empty());
assertEquals("S", sizeS);
final String sizeM = values.get(Optional.of("M"), Optional.empty());
assertEquals("M", sizeM);
final String sizeL = values.get(Optional.of("L"), Optional.empty());
assertEquals("L", sizeL);
}