当前位置: 首页>>代码示例>>Java>>正文


Java Table.get方法代码示例

本文整理汇总了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;
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:25,代码来源:ConfigRestService.java

示例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;
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:22,代码来源:ConfigRestService.java

示例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();
}
 
开发者ID:OWASP,项目名称:url-classifier,代码行数:23,代码来源:MediaTypeClassifierBuilder.java

示例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}

}
 
开发者ID:alxsimo,项目名称:guava-demo,代码行数:23,代码来源:TableSample.java

示例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());
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:30,代码来源:SpliceJunctionHelper.java

示例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;
}
 
开发者ID:AlbertSuarez,项目名称:Wikipedia-PROP,代码行数:27,代码来源:CliqueMaxim.java

示例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();
  }
}
 
开发者ID:synthetichealth,项目名称:synthea_java,代码行数:10,代码来源:DataStore.java

示例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);
			}
		}
	}
}
 
开发者ID:395299296,项目名称:librec-to-movies,代码行数:35,代码来源:RecommendMgr.java

示例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;
}
 
开发者ID:medialab-prado,项目名称:puremadrid,代码行数:11,代码来源:Parser.java

示例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();
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:42,代码来源:TableUtils.java

示例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);
}
 
开发者ID:fredhopper,项目名称:hybris-connector,代码行数:28,代码来源:ProductUrlProviderTest.java

示例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);
}
 
开发者ID:fredhopper,项目名称:hybris-connector,代码行数:36,代码来源:ProductUrlProviderTest.java

示例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);
}
 
开发者ID:fredhopper,项目名称:hybris-connector,代码行数:32,代码来源:SimpleAttributeProviderTest.java

示例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);

}
 
开发者ID:fredhopper,项目名称:hybris-connector,代码行数:42,代码来源:SimpleAttributeProviderTest.java

示例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);
}
 
开发者ID:fredhopper,项目名称:hybris-connector,代码行数:37,代码来源:SimpleAttributeProviderTest.java


注:本文中的com.google.common.collect.Table.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。