List of usage examples for com.google.common.collect Iterables get
public static <T> T get(Iterable<T> iterable, int position)
From source file:org.jclouds.azurecompute.arm.compute.domain.LocationAndName.java
public static LocationAndName fromSlashEncoded(String id) { Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id")); checkArgument(Iterables.size(parts) == 2, "id must be in format location/name"); return new AutoValue_LocationAndName(Iterables.get(parts, 0), Iterables.get(parts, 1)); }
From source file:org.jclouds.aliyun.ecs.domain.regionscoped.RegionAndId.java
public static RegionAndId fromSlashEncoded(String id) { Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id")); checkArgument(Iterables.size(parts) == 2, "id must be in format regionId/id"); return RegionAndId.create(Iterables.get(parts, 0), Iterables.get(parts, 1)); }
From source file:com.notifier.desktop.update.Version.java
public static Version parse(String s) { String number = Iterables.get(SNAPSHOT_SPLITTER.split(s), 0); Iterator<String> parts = NUMBER_SPLITTER.split(number).iterator(); int major, minor, incremental; major = minor = incremental = 0;//from w w w .ja va 2s. c om if (parts.hasNext()) { major = Integer.parseInt(parts.next()); } if (parts.hasNext()) { minor = Integer.parseInt(parts.next()); } if (parts.hasNext()) { incremental = Integer.parseInt(parts.next()); } return new Version(major, minor, incremental); }
From source file:org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName.java
public static ResourceGroupAndName fromSlashEncoded(String id) { Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id")); checkArgument(Iterables.size(parts) == 2, "id must be in format resourcegroup/name"); return new AutoValue_ResourceGroupAndName(Iterables.get(parts, 0), Iterables.get(parts, 1)); }
From source file:org.jclouds.googlecomputeengine.compute.domain.internal.RegionAndName.java
public static RegionAndName fromSlashEncoded(String name) { Iterable<String> parts = Splitter.on('/').split(checkNotNull(name, "name")); checkArgument(Iterables.size(parts) == 2, "name must be in format regionId/name"); return fromRegionAndName(Iterables.get(parts, 0), Iterables.get(parts, 1)); }
From source file:org.zalando.jpa.eclipselink.customizer.databasemapping.FieldInspector.java
static EntityFieldInspector<? extends Annotation> getFieldInspector(final DatabaseMapping databaseMapping) { final String attributeName = databaseMapping.getAttributeName(); final Class<?> entityClass = databaseMapping.getDescriptor().getJavaClass(); Set<Field> fieldsWithName = ReflectionUtils.getAllFields(entityClass, ReflectionUtils.withName(attributeName)); final Field field = Iterables.get(fieldsWithName, 0); // final Field field = ReflectionUtils.findField(entityClass, // attributeName); return new ColumnFieldInspector(field); }
From source file:org.jclouds.aliyun.ecs.compute.functions.internal.OperatingSystems.java
private static String parseVersion(Image image) { String sequence = image.osName().trim().replaceAll("\\s+", " "); int offset = 2; if (isWindows(image)) { sequence = image.platform();// w ww. j av a2 s. c o m offset = 1; } Iterable<String> splitted = Splitter.on(" ").split(sequence); return Iterables.get(splitted, Iterables.size(splitted) - offset); }
From source file:org.jclouds.openstack.nova.v2_0.domain.zonescoped.RegionAndId.java
public static RegionAndId fromSlashEncoded(String id) { Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id")); checkArgument(Iterables.size(parts) == 2, "id must be in format regionId/id"); return new RegionAndId(Iterables.get(parts, 0), Iterables.get(parts, 1)); }
From source file:com.facebook.presto.block.BlockIterables.java
public static BlockIterable createBlockIterable(Iterable<? extends Block> blocks) { TupleInfo tupleInfo = Iterables.get(blocks, 0).getTupleInfo(); return new StaticBlockIterable(tupleInfo, ImmutableList.copyOf(blocks)); }
From source file:com.alibaba.webmvc.extension.JSONs.java
@SuppressWarnings("unchecked") public static void writeTo(OutputStream out, Object value, Charset charset, boolean prettyPrint) { Map result = new HashMap(); if (value instanceof Map) { Map target = (Map) value; if (target.containsKey(SUCCESS)) { result.putAll(target);//from ww w . ja va 2 s . c o m } else if (target.containsKey(DATA)) { result.put(SUCCESS, true); result.put(DATA, target.get(DATA)); } else { result.put(SUCCESS, true); if (target.size() == 1) { result.put(DATA, Iterables.get(target.values(), 0)); } else { result.put(DATA, target); } } } else { result.put(DATA, value); result.put(SUCCESS, true); } if (prettyPrint) { JSON.writeJSONStringTo(result, new OutputStreamWriter(out, charset), SerializerFeature.PrettyFormat); } else { JSON.writeJSONStringTo(result, new OutputStreamWriter(out, charset)); } }