List of usage examples for com.google.common.collect Iterables isEmpty
public static boolean isEmpty(Iterable<?> iterable)
From source file:org.sonar.server.computation.task.projectanalysis.duplication.IntegrateCrossProjectDuplications.java
private void addDuplication(Component file, CloneGroup duplication) { ClonePart originPart = duplication.getOriginPart(); Iterable<Duplicate> duplicates = convertClonePartsToDuplicates(file, duplication); if (!Iterables.isEmpty(duplicates)) { duplicationRepository.add(file,/*from w w w . j av a 2 s . c o m*/ new Duplication(new TextBlock(originPart.getStartLine(), originPart.getEndLine()), duplicates)); } }
From source file:org.apache.brooklyn.entity.machine.MachineInitTasks.java
protected void openIptablesImpl(Iterable<Integer> inboundPorts, SshMachineLocation machine) { if (inboundPorts == null || Iterables.isEmpty(inboundPorts)) { log.info("No ports to open in iptables (no inbound ports) for {} at {}", machine, this); } else {//from www.j a v a 2 s.c om log.info("Opening ports in iptables for {} at {}", entity(), machine); List<String> iptablesRules = Lists.newArrayList(); String iptablesInstallCommands = null; Task<Integer> checkFirewall = checkLocationFirewall(machine); if (checkFirewall.getUnchecked() == 0) { for (Integer port : inboundPorts) { iptablesRules .add(IptablesCommands.addFirewalldRule(Chain.INPUT, Protocol.TCP, port, Policy.ACCEPT)); } } else { iptablesRules = createIptablesRulesForNetworkInterface(inboundPorts); iptablesInstallCommands = IptablesCommands.saveIptablesRules(); } insertIptablesRules(iptablesRules, iptablesInstallCommands, machine); listIptablesRules(machine); } }
From source file:com.google.devtools.j2objc.gen.RuntimeAnnotationGenerator.java
private void printParameterAnnotationMethods(MethodDeclaration method) { List<SingleVariableDeclaration> params = method.getParameters(); // Quick test to see if there are any parameter annotations. boolean hasAnnotations = false; for (SingleVariableDeclaration param : params) { if (!Iterables.isEmpty(TreeUtil.getRuntimeAnnotations(param.getAnnotations()))) { hasAnnotations = true;/*from www.j a va 2 s .c o m*/ break; } } if (hasAnnotations) { // Print array of arrays, with an element in the outer array for each parameter. printf("\n+ (IOSObjectArray *)__annotations_%s_params {\n", methodKey(method.getMethodBinding())); print(" return [IOSObjectArray arrayWithObjects:(id[]) { "); for (int i = 0; i < params.size(); i++) { if (i > 0) { print(", "); } SingleVariableDeclaration param = params.get(i); List<Annotation> runtimeAnnotations = TreeUtil.getRuntimeAnnotationsList(param.getAnnotations()); if (runtimeAnnotations.size() > 0) { print("[IOSObjectArray arrayWithObjects:(id[]) { "); printAnnotations(runtimeAnnotations); printf(" } count:%d type:JavaLangAnnotationAnnotation_class_()]", runtimeAnnotations.size()); } else { print("[IOSObjectArray arrayWithLength:0 type:JavaLangAnnotationAnnotation_class_()]"); } } printf(" } count:%d type:IOSClass_arrayOf(" + "JavaLangAnnotationAnnotation_class_())];\n}\n", params.size()); } }
From source file:org.icgc.dcc.portal.util.ElasticsearchResponseUtils.java
public static Boolean getBoolean(Object values) { val defaultValue = false; if (values == null) { return defaultValue; }/*from w ww. j av a 2 s . com*/ if (values instanceof Boolean) { return (Boolean) values; } if (values instanceof Iterable<?>) { val iterable = (Iterable<?>) values; return Iterables.isEmpty(iterable) ? defaultValue : Boolean.TRUE.equals(Iterables.get(iterable, 0)); } return defaultValue; }
From source file:com.google.devtools.j2objc.gen.TypeImplementationGenerator.java
private void printProperties() { Iterable<VariableDeclarationFragment> fields = Iterables.filter(getInstanceFields(), PROPERTIES); if (Iterables.isEmpty(fields)) { return;// w w w . jav a 2 s . c o m } newline(); for (VariableDeclarationFragment fragment : fields) { IVariableBinding varBinding = fragment.getVariableBinding(); String propertyName = nameTable.getVariableBaseName(varBinding); String varName = nameTable.getVariableShortName(varBinding); println("@synthesize " + propertyName + " = " + varName + ";"); } }
From source file:org.polymap.core.mapeditor.tooling.navi.NavigationTool.java
@Override public void toolingChanged(ToolingEvent ev) { super.toolingChanged(ev); // activate if no other is active if (ev.getSource() != this && ev.getType() == EventType.TOOL_DEACTIVATED && !isActive() // on the same hierarchy level && ev.getSource().getToolPath().segmentCount() == getToolPath().segmentCount()) { // check if there is any tool active - after all events have been processed Polymap.getSessionDisplay().asyncExec(new Runnable() { public void run() { IPath levelToolPath = getToolPath().removeLastSegments(1); if (Iterables.isEmpty(getSite().filterTools(EditorTools.hasStrictPrefix(levelToolPath), EditorTools.isActive()))) { getSite().triggerTool(getSite().getToolPath(), true); }//ww w.ja v a 2 s . c o m } }); } }
From source file:org.geogit.storage.memory.HeapGraphDatabase.java
@Override public boolean put(ObjectId commitId, ImmutableList<ObjectId> parentIds) { Node n = graph.getOrAdd(commitId); if (parentIds.isEmpty()) { // the root node, only update on first addition if (!n.isRoot()) { n.setRoot(true);//from ww w . j ava2 s . c om return true; } } // has the node been attached to graph? if (Iterables.isEmpty(n.to())) { // nope, attach it for (ObjectId parent : parentIds) { Node p = graph.getOrAdd(parent); graph.newEdge(n, p); } // only mark as updated if it is actually attached return !Iterables.isEmpty(n.to()); } return false; }
From source file:monasca.api.infrastructure.persistence.mysql.AlarmDefinitionMySqlRepoImpl.java
@Override public AlarmDefinition create(String tenantId, String id, String name, String description, String severity, String expression, Map<String, AlarmSubExpression> subExpressions, List<String> matchBy, List<String> alarmActions, List<String> okActions, List<String> undeterminedActions) { Handle h = db.open();//from ww w . j a v a 2 s . c o m try { h.begin(); h.insert( "insert into alarm_definition (id, tenant_id, name, description, severity, expression, match_by, actions_enabled, created_at, updated_at, deleted_at) values (?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW(), NULL)", id, tenantId, name, description, severity, expression, matchBy == null || Iterables.isEmpty(matchBy) ? null : COMMA_JOINER.join(matchBy), true); // Persist sub-alarms createSubExpressions(h, id, subExpressions); // Persist actions persistActions(h, id, AlarmState.ALARM, alarmActions); persistActions(h, id, AlarmState.OK, okActions); persistActions(h, id, AlarmState.UNDETERMINED, undeterminedActions); h.commit(); return new AlarmDefinition(id, name, description, severity, expression, matchBy, true, alarmActions, okActions == null ? Collections.<String>emptyList() : okActions, undeterminedActions == null ? Collections.<String>emptyList() : undeterminedActions); } catch (RuntimeException e) { h.rollback(); throw e; } finally { h.close(); } }
From source file:com.google.devtools.build.skyframe.ErrorInfo.java
public ErrorInfo(NestedSet<SkyKey> rootCauses, @Nullable Exception exception, SkyKey rootCauseOfException, ImmutableList<CycleInfo> cycles, boolean isTransient, boolean isCatostrophic) { Preconditions.checkState(exception != null || !Iterables.isEmpty(cycles), "At least one of exception and cycles must be non-null/empty, respectively"); Preconditions.checkState((exception == null) == (rootCauseOfException == null), "exception and rootCauseOfException must both be null or non-null, got %s %s", exception, rootCauseOfException);// w w w . j av a 2 s.c o m this.rootCauses = rootCauses; this.exception = exception; this.rootCauseOfException = rootCauseOfException; this.cycles = cycles; this.isTransient = isTransient; this.isCatastrophic = isCatostrophic; }
From source file:org.gradle.model.internal.inspect.ModelRuleSourceDetector.java
public boolean hasRules(Class<?> container) { return !Iterables.isEmpty(getDeclaredSources(container)); }