本文整理汇总了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;
}
示例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());
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例8: secondTypeParameter
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public String secondTypeParameter() {
return Iterables.get(typeParameters(), 1);
}
示例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);
}
示例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);
}
示例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))));
}
示例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)));
}
示例13: getDataType
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public DataType getDataType() {
return Iterables.get(possibleTypes, 0);
}