List of usage examples for com.google.common.collect ImmutableList size
int size();
From source file:elaborate.editor.model.ModelFactory.java
public static TranscriptionType getDefaultTranscriptionType() { ImmutableList<TranscriptionType> entities = transcriptionService.getTranscriptionTypes(); return entities.size() > 0 ? entities.get(0) : create(TranscriptionType.class).setName(TranscriptionType.DIPLOMATIC); }
From source file:com.facebook.presto.execution.QueryId.java
static List<String> parseDottedId(String id, int expectedParts, String name) { requireNonNull(id, "id is null"); checkArgument(expectedParts > 0, "expectedParts must be at least 1"); requireNonNull(name, "name is null"); ImmutableList<String> ids = ImmutableList.copyOf(Splitter.on('.').split(id)); checkArgument(ids.size() == expectedParts, "Invalid %s %s", name, id); for (String part : ids) { checkArgument(!part.isEmpty(), "Invalid id %s", id); checkArgument(ID_PATTERN.matcher(part).matches(), "Invalid id %s", id); }//from ww w .j a v a 2 s . c om return ids; }
From source file:com.facebook.presto.metadata.QualifiedObjectName.java
@JsonCreator public static QualifiedObjectName valueOf(String name) { requireNonNull(name, "name is null"); ImmutableList<String> ids = ImmutableList.copyOf(Splitter.on('.').split(name)); checkArgument(ids.size() == 3, "Invalid name %s", name); return new QualifiedObjectName(ids.get(0), ids.get(1), ids.get(2)); }
From source file:org.apache.calcite.rex.RexSubQuery.java
/** Creates an IN sub-query. */ public static RexSubQuery in(RelNode rel, ImmutableList<RexNode> nodes) { assert rel.getRowType().getFieldCount() == nodes.size(); final RelDataTypeFactory typeFactory = rel.getCluster().getTypeFactory(); boolean nullable = false; for (RexNode node : nodes) { if (node.getType().isNullable()) { nullable = true;/* w w w . j av a 2 s . c om*/ } } for (RelDataTypeField field : rel.getRowType().getFieldList()) { if (field.getType().isNullable()) { nullable = true; } } final RelDataType type = typeFactory .createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BOOLEAN), nullable); return new RexSubQuery(type, SqlStdOperatorTable.IN, nodes, rel); }
From source file:com.facebook.presto.metadata.QualifiedTableName.java
@JsonCreator public static QualifiedTableName valueOf(String tableName) { requireNonNull(tableName, "tableName is null"); ImmutableList<String> ids = ImmutableList.copyOf(Splitter.on('.').split(tableName)); checkArgument(ids.size() == 3, "Invalid tableName %s", tableName); return new QualifiedTableName(ids.get(0), ids.get(1), ids.get(2)); }
From source file:com.google.gcloud.datastore.PartialKey.java
static PartialKey fromPb(DatastoreV1.Key keyPb) { String dataset = null;// ww w.jav a 2s .c o m String namespace = null; if (keyPb.hasPartitionId()) { DatastoreV1.PartitionId partitionIdPb = keyPb.getPartitionId(); if (partitionIdPb.hasDatasetId()) { dataset = partitionIdPb.getDatasetId(); } if (partitionIdPb.hasNamespace()) { namespace = partitionIdPb.getNamespace(); } } List<DatastoreV1.Key.PathElement> pathElementsPb = keyPb.getPathElementList(); Preconditions.checkArgument(!pathElementsPb.isEmpty(), "Path must not be empty"); ImmutableList.Builder<PathElement> pathBuilder = ImmutableList.builder(); for (DatastoreV1.Key.PathElement pathElementPb : pathElementsPb) { pathBuilder.add(PathElement.fromPb(pathElementPb)); } ImmutableList<PathElement> path = pathBuilder.build(); PathElement leaf = path.get(path.size() - 1); if (leaf.nameOrId() != null) { return new Key(dataset, namespace, path); } return new PartialKey(dataset, namespace, path); }
From source file:com.google.devtools.build.lib.skyframe.ChainUniquenessUtils.java
private static ImmutableList<Object> canonicalize(ImmutableList<? extends Object> cycle) { int minPos = 0; String minString = cycle.get(0).toString(); for (int i = 1; i < cycle.size(); i++) { // TOOD(bazel-team): Is the toString representation stable enough? String candidateString = cycle.get(i).toString(); if (candidateString.compareTo(minString) < 0) { minPos = i;/*from www. j av a 2s. com*/ minString = candidateString; } } ImmutableList.Builder<Object> builder = ImmutableList.builder(); for (int i = 0; i < cycle.size(); i++) { int pos = (minPos + i) % cycle.size(); builder.add(cycle.get(pos)); } return builder.build(); }
From source file:com.teradata.tpcds.distribution.CalendarDistribution.java
public static int getMaxWeight(Weights weights) { ImmutableList<Integer> weightsList = getWeights(weights); return weightsList.get(weightsList.size() - 1); }
From source file:com.google.cloud.datastore.IncompleteKey.java
static IncompleteKey fromPb(com.google.datastore.v1.Key keyPb) { String projectId = ""; String namespace = ""; if (keyPb.hasPartitionId()) { com.google.datastore.v1.PartitionId partitionIdPb = keyPb.getPartitionId(); projectId = partitionIdPb.getProjectId(); namespace = partitionIdPb.getNamespaceId(); }//from w w w.j a va 2s . c om List<com.google.datastore.v1.Key.PathElement> pathElementsPb = keyPb.getPathList(); Preconditions.checkArgument(!pathElementsPb.isEmpty(), "Path must not be empty"); ImmutableList.Builder<PathElement> pathBuilder = ImmutableList.builder(); for (com.google.datastore.v1.Key.PathElement pathElementPb : pathElementsPb) { pathBuilder.add(PathElement.fromPb(pathElementPb)); } ImmutableList<PathElement> path = pathBuilder.build(); PathElement leaf = path.get(path.size() - 1); if (leaf.getNameOrId() != null) { return new Key(projectId, namespace, path); } return new IncompleteKey(projectId, namespace, path); }
From source file:com.mycompany.mavenproject3.Interpreter.java
public static Cons makeListHelp(ImmutableList<Sexpression> list) { // ImmutableList<Sexpression> list = ImmutableList.copyOf(sexpressions); if (list.isEmpty()) { return new Nil(); }/*from w ww .ja v a 2 s . c om*/ if (list.size() == 1) { return new Cons(list.get(0), new Nil()); } else { return new Cons(list.get(0), makeListHelp(list.subList(1, list.size() - 1))); } }