當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。