List of usage examples for com.google.common.collect Iterables get
public static <T> T get(Iterable<T> iterable, int position)
From source file:see.properties.impl.IterableResolver.java
@Override public Object get(Object bean, PropertyAccess property) { Iterable<?> list = (Iterable<?>) bean; int index = getIndex(property); return Iterables.get(list, index); }
From source file:org.jclouds.elasticstack.functions.KeyValuesDelimitedByBlankLinesToServerInfo.java
@Override public ServerInfo apply(HttpResponse response) { Set<ServerInfo> drives = setParser.apply(response); if (drives.size() == 0) return null; return Iterables.get(drives, 0); }
From source file:org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToProfileInfo.java
@Override public ProfileInfo apply(HttpResponse response) { Set<ProfileInfo> drives = setParser.apply(response); if (drives.size() == 0) return null; return Iterables.get(drives, 0); }
From source file:org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToStaticIPInfo.java
@Override public StaticIPInfo apply(HttpResponse response) { Set<StaticIPInfo> drives = setParser.apply(response); if (drives.size() == 0) return null; return Iterables.get(drives, 0); }
From source file:org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancer.java
@Override public LoadBalancer apply(HttpResponse arg0) { Map<String, LB> map = json.apply(arg0); if (map == null || map.size() == 0) return null; LB lb = Iterables.get(map.values(), 0); return convertLB.apply(lb); }
From source file:uk.gov.gchq.koryphe.impl.function.NthItem.java
@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"); }//from ww w .ja v a 2 s . c o m try { return Iterables.get(input, selection); } finally { CloseableUtil.close(input); } }
From source file:com.eucalyptus.simpleworkflow.stateful.AbstractTaskPolledNotificationChecker.java
@Override public boolean apply(final String channel) { final Iterable<String> channelName = Splitter.on(':').limit(4).split(channel); if (Iterables.size(channelName) == 4) { final String accountNumber = Iterables.get(channelName, 0); final String type = Iterables.get(channelName, 1); final String domain = Iterables.get(channelName, 2); final String taskList = Iterables.get(channelName, 3); if (this.type.equals(type)) try { return hasTasks(accountNumber, domain, taskList); } catch (final Exception e) { logger.error("Error checking for pending tasks", e); }//from w w w. j ava 2 s . c om } return false; }
From source file:com.cinchapi.concourse.lang.ast.ConjunctionTree.java
/** * Return the right child of this {@link ConjunctionTree}. * * @return the right child */ public AST getRightChild() { return Iterables.get(children(), 1); }
From source file:net.sourceforge.cilib.util.selection.weighting.EntityWeighting.java
@Override public <T> Iterable<WeightedObject> weigh(Iterable<T> iterable) { Preconditions.checkArgument(Iterables.get(iterable, 0) instanceof Entity); MinMaxFitness minMaxFitness = getMinMaxFitness(Lists.newArrayList(iterable)); List<WeightedObject> result = Lists.newArrayList(); if (minMaxFitness.getFirst() == InferiorFitness.instance() || minMaxFitness.getSecond() == InferiorFitness.instance()) { throw new UnsupportedOperationException( "Cannot weigh entities where all entities have Inferior fitness."); }//w ww.j a v a 2 s. c o m double minMaxDifference = minMaxFitness.getSecond().getValue() - minMaxFitness.getFirst().getValue(); for (T t : iterable) { double weight = (this.entityFitness.getFitness((Entity) t).getValue() - minMaxFitness.getFirst().getValue()) / minMaxDifference; result.add(new WeightedObject(t, weight)); } return result; }
From source file:org.apache.brooklyn.entity.nosql.hazelcast.HazelcastTestHelper.java
public static void testHazelcastCluster(TestApplication app, Location loc) { HazelcastCluster cluster = app.createAndManageChild( EntitySpec.create(HazelcastCluster.class).configure(HazelcastCluster.INITIAL_SIZE, 3) .configure(HazelcastCluster.MEMBER_SPEC, EntitySpec.create(HazelcastNode.class))); app.start(ImmutableList.of(loc));/* w w w. j a va 2s. c o m*/ EntityAsserts.assertAttributeEqualsEventually(cluster, HazelcastNode.SERVICE_UP, true); HazelcastNode first = (HazelcastNode) Iterables.get(cluster.getMembers(), 0); HazelcastNode second = (HazelcastNode) Iterables.get(cluster.getMembers(), 1); assertNodesUpAndInCluster(first, second); EntityAsserts.assertAttributeEqualsEventually(cluster, Attributes.SERVICE_UP, true); }