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


Java Iterables.get方法代码示例

本文整理汇总了Java中com.google.common.collect.Iterables.get方法的典型用法代码示例。如果您正苦于以下问题:Java Iterables.get方法的具体用法?Java Iterables.get怎么用?Java Iterables.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.Iterables的用法示例。


在下文中一共展示了Iterables.get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: evalueer

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public Expressie evalueer(final Context context) {
    final Object contextwaarde = resolveContextwaarde(context);
    final List<Resolver> solversVoorContextObject = resolverList.stream().filter(resolver1 -> resolver1.matchContext(contextwaarde))
            .collect(Collectors.toList());
    if (solversVoorContextObject.isEmpty()) {
        throw new ExpressieRuntimeException("Expressie kan niet uitgevoerd worden op het gegeven contextobject");
    }
    final Resolver resolver = Iterables.get(solversVoorContextObject, 0);
    final Persoonslijst persoonslijst = context.getProperty(ExpressieTaalConstanten.CONTEXT_PROPERTY_PERSOONSLIJST);
    final Predicate<MetaAttribuut> attribuutFilter = resolver.postFilter()
            ? bepaalAttribuutFilter(context, persoonslijst)
            : metaAttribuut -> true;
    final Collection solve = resolver.apply(persoonslijst.getModelIndex(), contextwaarde);
    final LijstExpressie resultaatLijst = maakResultaatLijst(attribuutFilter, solve, context);
    LOGGER.debug("resultaat = {}", resultaatLijst);
    return resultaatLijst;
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:19,代码来源:ElementExpressie.java

示例2: pickInstance

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private <T> T pickInstance(Collection<T> instances, T defaultValue) {
  if (instances.isEmpty()) {
    return defaultValue;
  }
  // generateInt() is 1-based.
  return Iterables.get(instances, (generateInt() - 1) % instances.size());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:FreshValueGenerator.java

示例3: TODO

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@AndroidIncompatible // TODO(cpovirk): Look up Build.VERSION.SDK_INT reflectively.
public void testCreate() {
  Closer closer = Closer.create();
  String javaVersion = System.getProperty("java.version");
  String secondPart = Iterables.get(Splitter.on('.').split(javaVersion), 1);
  int versionNumber = Integer.parseInt(secondPart);
  if (versionNumber < 7) {
    assertThat(closer.suppressor).isInstanceOf(Closer.LoggingSuppressor.class);
  } else {
    assertThat(closer.suppressor).isInstanceOf(Closer.SuppressingSuppressor.class);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:13,代码来源:CloserTest.java

示例4: buildScreenPane

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private GridPane buildScreenPane( final Iterable<Object> buildsInScreen, final int nbColums, final int byColums ) {
    final GridPane screenPane = new GridPane( );
    screenPane.setHgap( GAP_SPACE );
    screenPane.setVgap( GAP_SPACE );
    screenPane.setPadding( new Insets( GAP_SPACE ) );
    screenPane.setStyle( "-fx-background-color:black;" );
    screenPane.setAlignment( Pos.CENTER );

    final Iterable<List<Object>> partition = Iterables.paddedPartition( buildsInScreen, byColums );
    for ( int x = 0; x < nbColums; x++ ) {
        final List<Object> buildList = x < size( partition ) ? Iterables.get( partition, x ) : Collections.emptyList( );
        for ( int y = 0; y < byColums; y++ ) {
            if ( buildList.isEmpty( ) ) {
                createEmptyTile( screenPane, x, y, nbColums, byColums );
                continue;
            }

            final Object build = Iterables.get( buildList, y );
            if ( build == null )
                createEmptyTile( screenPane, x, y, nbColums, byColums );
            else
                createTileFromModel( screenPane, build, x, y, nbColums, byColums );
        }
    }

    return screenPane;
}
 
开发者ID:u2032,项目名称:wall-t,代码行数:28,代码来源:WallView.java

示例5: get

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public Object get(Object key) {
    if ("size".equals(key)) {
        return col.size();
    } else if (key instanceof Number) {
        return Iterables.get(col, ((Number) key).intValue());
    }
    try {
        int index = Integer.parseInt(key.toString());
        return Iterables.get(col, index);
    } catch (NumberFormatException nfe) {
        // if it's not a number it is as if the key doesn't exist
        return null;
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:16,代码来源:CustomReflectionObjectHandler.java

示例6: apply

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
@SuppressFBWarnings(value = "DE_MIGHT_IGNORE", justification = "Any exceptions are to be ignored")
public T apply(final Iterable<T> input) {
    if (null == input) {
        throw new IllegalArgumentException("Input cannot be null");
    }
    try {
        return Iterables.get(input, selection);
    } finally {
        CloseableUtil.close(input);
    }
}
 
开发者ID:gchq,项目名称:koryphe,代码行数:13,代码来源:NthItem.java

示例7: fixConfigurations

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private void fixConfigurations(String activeConfig) {
    if (configs.isEmpty()) {
        configs.put(DEFAULT_CONFIG.getDisplayName(), DEFAULT_CONFIG);
    }
    if (activeConfig != null && configs.containsKey(activeConfig)) {
        activeConfigName = activeConfig;
    } else {
        activeConfigName = Iterables.get(configs.keySet(), 0);
    }
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:11,代码来源:AndroidConfigProvider.java

示例8: secondTypeParameter

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public String secondTypeParameter() {
  return Iterables.get(typeParameters(), 1);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:ValueAttribute.java

示例9: getSingleElement

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public IEObjectDescription getSingleElement(QualifiedName name) {
	final Iterable<IEObjectDescription> result = getElements(name);
	int size = Iterables.size(result);
	if (size == 1) {
		return result.iterator().next();
	}

	// Special case handling when we have a definition and a pure JS file in the score.
	// In such cases we return with the description that corresponds to the definition file.
	if (size == 2) {

		final IEObjectDescription first = Iterables.get(result, 0);
		final IEObjectDescription second = Iterables.get(result, 1);

		final String firstExtension = first.getEObjectURI().fileExtension();
		final String secondExtension = second.getEObjectURI().fileExtension();

		if (JS_FILE_EXTENSION.equals(firstExtension) && N4JSD_FILE_EXTENSION.equals(secondExtension)) {
			return second;
		}

		if (N4JSD_FILE_EXTENSION.equals(firstExtension) && JS_FILE_EXTENSION.equals(secondExtension)) {
			return first;
		}

	}

	// if no import declaration was given, we skip the advanced error reporting
	if (!importDeclaration.isPresent()) {
		return null;
	}

	// handle error cases to help user fix the issue
	StringBuilder sbErrrorMessage = new StringBuilder("Cannot resolve import target ::");

	ImportType importType = computeImportType(name, this.contextProject);
	switch (importType) {
	case PROJECT_IMPORT:
		sbErrrorMessage.append(" resolving project import :");
		break;
	case COMPLETE_IMPORT:
		sbErrrorMessage.append(" resolving full module import :");
		break;
	case SIMPLE_IMPORT:
		sbErrrorMessage.append(" resolving simple module import :");
		break;
	case PROJECT_IMPORT_NO_MAIN:
		sbErrrorMessage.append(" no main module in target project");
		break;
	default:
		sbErrrorMessage.append(" unrecognized import structure :");
		break;
	}

	if (!importType.equals(ImportType.PROJECT_IMPORT_NO_MAIN)) {
		if (size == 0) {
			sbErrrorMessage.append(" found no matching modules");
		} else {
			sbErrrorMessage.append(" found multiple matching modules ");
			sbErrrorMessage.append(IterableExtensions.join(result, ","));
		}
	}

	final EObject originalProxy = (EObject) this.importDeclaration.get()
			.eGet(N4JSPackage.eINSTANCE.getImportDeclaration_Module(), false);
	return new InvalidImportTargetModuleDescription(EObjectDescription.create("impDecl", originalProxy),
			sbErrrorMessage.toString(), IssueCodes.IMP_UNRESOLVED);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:70,代码来源:ProjectImportEnablingScope.java

示例10: getGeneralPlans

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private List<OptimizedPlan> getGeneralPlans() throws PlannerException {
	HashBasedTable<Table, Expressible, PlanPath> matrix = cm.getMatrix();
	ArrayList<Table> sortKeys = cm.getSortedKeys();

	// sort for cost then prune for virtuals
	cm.applyDefaultSort();
	logger.debug("Default sorted cost matrix at start of generating general plans: \n"+cm.toString());

	List<OptimizedPlan> pls = Lists.newArrayList();

	List<Expressible> measures = matrix.columnKeySet().stream().filter((vn) -> {
		return (vn instanceof Measure);
		
	}).collect(Collectors.toList());

	List<Expressible> dims = matrix.columnKeySet().stream().filter((vn) -> {
		return (vn instanceof Dimension);
	}).collect(Collectors.toList());

	int i=0;
	Map<Table, Map<Expressible, PlanPath>> map = matrix.rowMap();
	while(!measures.isEmpty()){
		if(i>sortKeys.size()-1)
			throw new PlannerException("Unresolvable measures: " +measures);

		Table row = Iterables.get(sortKeys,i);
		//skip if row has no measures.
		if(skipRow(row)){
			i++;
			continue;
		}

		OptimizedPlan op = new OptimizedPlan();
		int count = 0;
		double cost = 0;
		ArrayList<Expressible> dimStack = Lists.newArrayList(dims);

		// sometimes muliple roots can support a measure
		// if the measure is already resolved then we
		// dont need to add anymore plans that can support the same measure.
		boolean addPlan = false;
		for(Entry<Expressible, PlanPath> v : map.get(row).entrySet()){
			// set addPlan to true if we actually are able to
			// take a measure of the stack.
			if(measures.remove(v.getKey())) addPlan = true;
			dimStack.remove(v.getKey());
			op.addPath(v.getValue());
			cost += v.getValue().getCost();
			count++;
		}
		if(!addPlan){
			i++;
			continue;
		}

		op.setPlanCost(cost/count);
		op.addDisjointedPlans(getDisjoinPlans(dimStack,op));
		//cm.applyDefaultSort();
		pls.add(op);
		i++;
	}

	return processForCostOptimization(pls);
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:65,代码来源:PlanGenerator.java

示例11: randomElement

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
default <T> T randomElement(Iterable<T> iterable) {
    return Iterables.get(iterable, randomInt(Range.closedOpen(0, Iterables.size(iterable))));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:Entropy.java

示例12: element

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public static <T> T element(Random random, Iterable<? extends T> collection) {
    return Iterables.get(collection, safeNextInt(random, Iterables.size(collection)));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:RandomUtils.java

示例13: getDataType

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public DataType getDataType() {
  return Iterables.get(possibleTypes, 0);
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:5,代码来源:DestroyedSource.java


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