List of usage examples for com.google.common.collect ImmutableList contains
boolean contains(Object o);
From source file:org.apache.isis.core.metamodel.services.grid.bootstrap3.GridSystemServiceBS3.java
protected void addPropertiesTo(final FieldSet fieldSet, final List<String> propertyIds, final LinkedHashMap<String, PropertyLayoutData> propertyLayoutDataById) { final ImmutableList<String> existingIds = FluentIterable.from(fieldSet.getProperties()) .transform(new Function<PropertyLayoutData, String>() { @Nullable//from w ww . ja v a2s . c o m @Override public String apply(@Nullable final PropertyLayoutData propertyLayoutData) { return propertyLayoutData.getId(); } }).toList(); for (final String propertyId : propertyIds) { if (!existingIds.contains(propertyId)) { final PropertyLayoutData propertyLayoutData = new PropertyLayoutData(propertyId); fieldSet.getProperties().add(propertyLayoutData); propertyLayoutData.setOwner(fieldSet); propertyLayoutDataById.put(propertyId, propertyLayoutData); } } }
From source file:org.geogit.api.plumbing.merge.ReportCommitConflictsOp.java
@Override public MergeScenarioReport call() { MergeScenarioReport report = new MergeScenarioReport(); ObjectId parentCommitId = ObjectId.NULL; if (commit.getParentIds().size() > 0) { parentCommitId = commit.getParentIds().get(0); }/*w w w.ja va 2 s. c o m*/ ObjectId parentTreeId = ObjectId.NULL; if (repository.commitExists(parentCommitId)) { parentTreeId = repository.getCommit(parentCommitId).getTreeId(); } // get changes Iterator<DiffEntry> diffs = command(DiffTree.class).setOldTree(parentTreeId).setNewTree(commit.getTreeId()) .setReportTrees(true).call(); while (diffs.hasNext()) { DiffEntry diff = diffs.next(); String path = diff.oldPath() == null ? diff.newPath() : diff.oldPath(); Optional<RevObject> obj = command(RevObjectParse.class).setRefSpec(Ref.HEAD + ":" + path).call(); switch (diff.changeType()) { case ADDED: if (obj.isPresent()) { TYPE type = command(ResolveObjectType.class).setObjectId(diff.getNewObject().objectId()).call(); if (TYPE.TREE.equals(type)) { NodeRef headVersion = command(FindTreeChild.class).setChildPath(path) .setParent(repository.getOrCreateHeadTree()).call().get(); if (!headVersion.getMetadataId().equals(diff.getNewObject().getMetadataId())) { report.addConflict(new Conflict(path, ObjectId.NULL, diff.getNewObject().getMetadataId(), headVersion.getMetadataId())); } } else { if (!obj.get().getId().equals(diff.newObjectId())) { report.addConflict( new Conflict(path, ObjectId.NULL, diff.newObjectId(), obj.get().getId())); } } } else { report.addUnconflicted(diff); } break; case REMOVED: if (obj.isPresent()) { if (obj.get().getId().equals(diff.oldObjectId())) { report.addUnconflicted(diff); } else { report.addConflict( new Conflict(path, diff.oldObjectId(), ObjectId.NULL, obj.get().getId())); } } break; case MODIFIED: TYPE type = command(ResolveObjectType.class).setObjectId(diff.getNewObject().objectId()).call(); if (TYPE.TREE.equals(type)) { // TODO:see how to do this. For now, we will pass any change as a conflicted // one report.addUnconflicted(diff); } else { String refSpec = Ref.HEAD + ":" + path; obj = command(RevObjectParse.class).setRefSpec(refSpec).call(); if (!obj.isPresent()) { // git reports this as a conflict but does not mark as conflicted, just adds // the missing file. // We add it and consider it unconflicted report.addUnconflicted(diff); break; } RevFeature feature = (RevFeature) obj.get(); DepthSearch depthSearch = new DepthSearch(repository.getObjectDatabase()); Optional<NodeRef> noderef = depthSearch.find(this.getWorkTree().getTree(), path); RevFeatureType featureType = command(RevObjectParse.class) .setObjectId(noderef.get().getMetadataId()).call(RevFeatureType.class).get(); ImmutableList<PropertyDescriptor> descriptors = featureType.sortedDescriptors(); FeatureDiff featureDiff = command(DiffFeature.class) .setOldVersion(Suppliers.ofInstance(diff.getOldObject())) .setNewVersion(Suppliers.ofInstance(diff.getNewObject())).call(); Set<Entry<PropertyDescriptor, AttributeDiff>> attrDiffs = featureDiff.getDiffs().entrySet(); boolean ok = true; for (Iterator<Entry<PropertyDescriptor, AttributeDiff>> iterator = attrDiffs .iterator(); iterator.hasNext() && ok;) { Entry<PropertyDescriptor, AttributeDiff> entry = iterator.next(); AttributeDiff attrDiff = entry.getValue(); PropertyDescriptor descriptor = entry.getKey(); switch (attrDiff.getType()) { case ADDED: if (descriptors.contains(descriptor)) { ok = false; } break; case REMOVED: case MODIFIED: if (!descriptors.contains(descriptor)) { ok = false; break; } for (int i = 0; i < descriptors.size(); i++) { if (descriptors.get(i).equals(descriptor)) { Optional<Object> value = feature.getValues().get(i); if (!attrDiff.canBeAppliedOn(value)) { ok = false; } break; } } } } if (ok) { report.addUnconflicted(diff); } else { report.addConflict( new Conflict(path, diff.oldObjectId(), diff.newObjectId(), obj.get().getId())); } } break; } } return report; }
From source file:org.obiba.mica.core.upgrade.Mica310Upgrade.java
private void addDefaultFacets() { logger.info("Add default facets in study taxonomy"); ImmutableList<String> vocabulariesWithFacet = ImmutableList.<String>builder().add("methods-design") .add("start").add("end").add("populations-selectionCriteria-countriesIso") .add("populations-selectionCriteria-ageMin").add("populations-selectionCriteria-ageMax") .add("populations-selectionCriteria-gender").add("populations-selectionCriteria-pregnantWomen") .add("populations-selectionCriteria-newborn").add("populations-selectionCriteria-twins") .add("numberOfParticipants-participant-number").add("numberOfParticipants-sample-number") .add("methods-recruitments").add("populations-recruitment-dataSources") .add("populations-dataCollectionEvents-dataSources") .add("populations-dataCollectionEvents-bioSamples").add("access", "19").build(); Taxonomy studyTaxonomy = taxonomyConfigService.findByTarget(TaxonomyTarget.STUDY); for (Vocabulary vocabulary : studyTaxonomy.getVocabularies()) { if (vocabulariesWithFacet.contains(vocabulary.getName())) { vocabulary.addAttribute("facet", "true"); vocabulary.addAttribute("facetPosition", "0"); vocabulary.addAttribute("facetExpanded", "false"); }//www .j a v a 2s. c o m } taxonomyConfigService.update(TaxonomyTarget.STUDY, studyTaxonomy); }
From source file:org.jenkinsci.plugins.blockbuildfinalproject.BlockBuild.java
/** * Returns all the transitive upstream or downstream projects. Recursion stops if a project is in finalProjects. * /* ww w.jav a 2 s . co m*/ * @param finalProjects list of projects to stop searching * @param direction direction to search, either UP for upstream projects or DOWN for downstream projects * @return list of transitive projects * * This method is similar to DependencyGraph.getTransitiveDownstream(). * The difference is this method will stop searching down a branch if it encounters a * project in the finalProjects list. */ private Set<AbstractProject<?, ?>> getTransitiveUpOrDownstreamProjectsFinal(ImmutableList<String> finalProjects, SearchDirection direction) { Set<AbstractProject<?, ?>> visited = new HashSet<AbstractProject<?, ?>>(); Stack<AbstractProject<?, ?>> queue = new Stack<AbstractProject<?, ?>>(); finalProjects = checkFinalProjectsForNull(finalProjects); LOGGER.finest("Finding " + direction.name().toLowerCase() + "stream projects for " + project.getFullName()); queue.add(project); while (!queue.isEmpty()) { AbstractProject<?, ?> currentProject = queue.pop(); @SuppressWarnings("rawtypes") List<AbstractProject> dependencyProjects; if (direction == SearchDirection.UP) { dependencyProjects = currentProject.getUpstreamProjects(); } else { dependencyProjects = currentProject.getDownstreamProjects(); } for (AbstractProject<?, ?> childProject : dependencyProjects) { if (visited.add(childProject)) { LOGGER.finest("Adding child project " + childProject.getFullName() + " to list of projects."); if (finalProjects.contains(childProject.getFullName())) { LOGGER.finer("Final project " + childProject.getFullName() + " found." + " Will not transervse deeper."); // Note: project is NOT added to the queue. } else { queue.add(childProject); } } } } return visited; }
From source file:org.locationtech.geogig.api.plumbing.merge.ReportCommitConflictsOp.java
@Override protected MergeScenarioReport _call() { MergeScenarioReport report = new MergeScenarioReport(); ObjectId parentCommitId = ObjectId.NULL; if (commit.getParentIds().size() > 0) { parentCommitId = commit.getParentIds().get(0); }// w ww . j a v a 2 s . co m ObjectId parentTreeId = ObjectId.NULL; Repository repository = repository(); if (repository.commitExists(parentCommitId)) { parentTreeId = repository.getCommit(parentCommitId).getTreeId(); } // get changes Iterator<DiffEntry> diffs = command(DiffTree.class).setOldTree(parentTreeId).setNewTree(commit.getTreeId()) .setReportTrees(true).call(); while (diffs.hasNext()) { DiffEntry diff = diffs.next(); String path = diff.oldPath() == null ? diff.newPath() : diff.oldPath(); Optional<RevObject> obj = command(RevObjectParse.class).setRefSpec(Ref.HEAD + ":" + path).call(); switch (diff.changeType()) { case ADDED: if (obj.isPresent()) { TYPE type = command(ResolveObjectType.class).setObjectId(diff.getNewObject().objectId()).call(); if (TYPE.TREE.equals(type)) { NodeRef headVersion = command(FindTreeChild.class).setChildPath(path) .setParent(repository.getOrCreateHeadTree()).call().get(); if (!headVersion.getMetadataId().equals(diff.getNewObject().getMetadataId())) { report.addConflict(new Conflict(path, ObjectId.NULL, diff.getNewObject().getMetadataId(), headVersion.getMetadataId())); } } else { if (!obj.get().getId().equals(diff.newObjectId())) { report.addConflict( new Conflict(path, ObjectId.NULL, diff.newObjectId(), obj.get().getId())); } } } else { report.addUnconflicted(diff); } break; case REMOVED: if (obj.isPresent()) { if (obj.get().getId().equals(diff.oldObjectId())) { report.addUnconflicted(diff); } else { report.addConflict( new Conflict(path, diff.oldObjectId(), ObjectId.NULL, obj.get().getId())); } } break; case MODIFIED: TYPE type = command(ResolveObjectType.class).setObjectId(diff.getNewObject().objectId()).call(); if (TYPE.TREE.equals(type)) { // TODO:see how to do this. For now, we will pass any change as a conflicted // one if (!diff.isChange()) { report.addUnconflicted(diff); } } else { String refSpec = Ref.HEAD + ":" + path; obj = command(RevObjectParse.class).setRefSpec(refSpec).call(); if (!obj.isPresent()) { // git reports this as a conflict but does not mark as conflicted, just adds // the missing file. // We add it and consider it unconflicted report.addUnconflicted(diff); break; } RevFeature feature = (RevFeature) obj.get(); DepthSearch depthSearch = new DepthSearch(repository.objectDatabase()); Optional<NodeRef> noderef = depthSearch.find(this.workingTree().getTree(), path); RevFeatureType featureType = command(RevObjectParse.class) .setObjectId(noderef.get().getMetadataId()).call(RevFeatureType.class).get(); ImmutableList<PropertyDescriptor> descriptors = featureType.sortedDescriptors(); FeatureDiff featureDiff = command(DiffFeature.class) .setOldVersion(Suppliers.ofInstance(diff.getOldObject())) .setNewVersion(Suppliers.ofInstance(diff.getNewObject())).call(); Set<Entry<PropertyDescriptor, AttributeDiff>> attrDiffs = featureDiff.getDiffs().entrySet(); RevFeature newFeature = command(RevObjectParse.class).setObjectId(diff.newObjectId()) .call(RevFeature.class).get(); boolean ok = true; for (Iterator<Entry<PropertyDescriptor, AttributeDiff>> iterator = attrDiffs .iterator(); iterator.hasNext() && ok;) { Entry<PropertyDescriptor, AttributeDiff> entry = iterator.next(); AttributeDiff attrDiff = entry.getValue(); PropertyDescriptor descriptor = entry.getKey(); switch (attrDiff.getType()) { case ADDED: if (descriptors.contains(descriptor)) { ok = false; } break; case REMOVED: case MODIFIED: if (!descriptors.contains(descriptor)) { ok = false; break; } for (int i = 0; i < descriptors.size(); i++) { if (descriptors.get(i).equals(descriptor)) { Optional<Object> value = feature.getValues().get(i); Optional<Object> newValue = newFeature.getValues().get(i); if (!newValue.equals(value)) { // if it's going to end up // setting the same value, it is // compatible, so no need to // check if (!attrDiff.canBeAppliedOn(value)) { ok = false; } break; } } } } } if (ok) { report.addUnconflicted(diff); } else { report.addConflict( new Conflict(path, diff.oldObjectId(), diff.newObjectId(), obj.get().getId())); } } break; } } return report; }
From source file:com.google.cloud.dns.testing.LocalDnsHelper.java
@VisibleForTesting Response deleteZone(String projectId, String zoneName) { ZoneContainer zone = findZone(projectId, zoneName); ImmutableSortedMap<String, ResourceRecordSet> rrsets = zone == null ? ImmutableSortedMap.<String, ResourceRecordSet>of() : zone.dnsRecords().get();/*from w w w .ja v a2 s.c o m*/ ImmutableList<String> defaults = ImmutableList.of("NS", "SOA"); for (ResourceRecordSet current : rrsets.values()) { if (!defaults.contains(current.getType())) { return Error.CONTAINER_NOT_EMPTY.response(String .format("The resource named '%s' cannot be deleted because it is not empty", zoneName)); } } ProjectContainer projectContainer = projects.get(projectId); ZoneContainer previous = projectContainer.zones.remove(zoneName); return previous == null ? Error.NOT_FOUND.response( String.format("The 'parameters.managedZone' resource named '%s' does not exist.", zoneName)) : new Response(HTTP_NO_CONTENT, "{}"); }
From source file:org.locationtech.geogig.plumbing.merge.ReportCommitConflictsOp.java
@Override protected MergeScenarioReport _call() { Preconditions.checkArgument(consumer != null, "No consumer provided."); MergeScenarioReport report = new MergeScenarioReport(); ObjectId parentCommitId = ObjectId.NULL; if (commit.getParentIds().size() > 0) { parentCommitId = commit.getParentIds().get(0); }//from w w w . ja va 2 s. co m ObjectId parentTreeId = ObjectId.NULL; Repository repository = repository(); if (repository.commitExists(parentCommitId)) { parentTreeId = repository.getCommit(parentCommitId).getTreeId(); } // get changes try (AutoCloseableIterator<DiffEntry> diffs = command(DiffTree.class).setOldTree(parentTreeId) .setNewTree(commit.getTreeId()).setReportTrees(true).call()) { while (diffs.hasNext()) { DiffEntry diff = diffs.next(); String path = diff.oldPath() == null ? diff.newPath() : diff.oldPath(); Optional<RevObject> obj = command(RevObjectParse.class).setRefSpec(Ref.HEAD + ":" + path).call(); switch (diff.changeType()) { case ADDED: if (obj.isPresent()) { TYPE type = command(ResolveObjectType.class).setObjectId(diff.getNewObject().getObjectId()) .call(); if (TYPE.TREE.equals(type)) { NodeRef headVersion = command(FindTreeChild.class).setChildPath(path) .setParent(repository.getOrCreateHeadTree()).call().get(); if (!headVersion.getMetadataId().equals(diff.getNewObject().getMetadataId())) { consumer.conflicted(new Conflict(path, ObjectId.NULL, diff.getNewObject().getMetadataId(), headVersion.getMetadataId())); report.addConflict(); } } else { if (!obj.get().getId().equals(diff.newObjectId())) { consumer.conflicted( new Conflict(path, ObjectId.NULL, diff.newObjectId(), obj.get().getId())); report.addConflict(); } } } else { consumer.unconflicted(diff); report.addUnconflicted(); } break; case REMOVED: if (obj.isPresent()) { if (obj.get().getId().equals(diff.oldObjectId())) { consumer.unconflicted(diff); report.addUnconflicted(); } else { consumer.conflicted( new Conflict(path, diff.oldObjectId(), ObjectId.NULL, obj.get().getId())); report.addConflict(); } } break; case MODIFIED: TYPE type = command(ResolveObjectType.class).setObjectId(diff.getNewObject().getObjectId()) .call(); if (TYPE.TREE.equals(type)) { // TODO:see how to do this. For now, we will pass any change as a conflicted // one if (!diff.isChange()) { consumer.unconflicted(diff); report.addUnconflicted(); } } else { String refSpec = Ref.HEAD + ":" + path; obj = command(RevObjectParse.class).setRefSpec(refSpec).call(); if (!obj.isPresent()) { // git reports this as a conflict but does not mark as conflicted, just // adds // the missing file. // We add it and consider it unconflicted consumer.unconflicted(diff); report.addUnconflicted(); break; } RevFeature feature = (RevFeature) obj.get(); DepthSearch depthSearch = new DepthSearch(repository.objectDatabase()); Optional<NodeRef> noderef = depthSearch.find(this.workingTree().getTree(), path); RevFeatureType featureType = command(RevObjectParse.class) .setObjectId(noderef.get().getMetadataId()).call(RevFeatureType.class).get(); ImmutableList<PropertyDescriptor> descriptors = featureType.descriptors(); FeatureDiff featureDiff = command(DiffFeature.class) .setOldVersion(Suppliers.ofInstance(diff.getOldObject())) .setNewVersion(Suppliers.ofInstance(diff.getNewObject())).call(); Set<Entry<PropertyDescriptor, AttributeDiff>> attrDiffs = featureDiff.getDiffs().entrySet(); RevFeature newFeature = command(RevObjectParse.class).setObjectId(diff.newObjectId()) .call(RevFeature.class).get(); boolean ok = true; for (Iterator<Entry<PropertyDescriptor, AttributeDiff>> iterator = attrDiffs .iterator(); iterator.hasNext() && ok;) { Entry<PropertyDescriptor, AttributeDiff> entry = iterator.next(); AttributeDiff attrDiff = entry.getValue(); PropertyDescriptor descriptor = entry.getKey(); switch (attrDiff.getType()) { case ADDED: if (descriptors.contains(descriptor)) { ok = false; } break; case REMOVED: case MODIFIED: if (!descriptors.contains(descriptor)) { ok = false; break; } for (int i = 0; i < descriptors.size(); i++) { if (descriptors.get(i).equals(descriptor)) { Optional<Object> value = feature.get(i); Optional<Object> newValue = newFeature.get(i); if (!newValue.equals(value)) { // if it's going to end up // setting the same value, it // is // compatible, so no need to // check if (!attrDiff.canBeAppliedOn(value.orNull())) { ok = false; } break; } } } } } if (ok) { consumer.unconflicted(diff); report.addUnconflicted(); } else { consumer.conflicted( new Conflict(path, diff.oldObjectId(), diff.newObjectId(), obj.get().getId())); report.addConflict(); } } break; } } } consumer.finished(); return report; }
From source file:com.android.tools.idea.editors.theme.NewStyleDialog.java
/** * Creates a new style dialog. This dialog it's used both to create new themes and new styles. * @param isTheme Whether the new item will be a theme or a regular style. This will only affect the messages displayed to user. * @param context The current theme editor context. * @param defaultParentName The parent style that will be preselected in the parent text field. * @param currentThemeName The current theme name. This is used to automatically generate style names suggestions. * @param message Message to display to the user when creating the new style. *///from w w w .ja v a2s. c o m public NewStyleDialog(boolean isTheme, @NotNull ThemeEditorContext context, @Nullable String defaultParentName, @Nullable final String currentThemeName, @Nullable String message) { super(true); if (!Strings.isNullOrEmpty(message)) { myMessageLabel.setText(message); myMessageLabel.setVisible(true); } else { myMessageLabel.setVisible(false); } final Configuration configuration = context.getConfiguration(); myResourceNameValidator = ResourceNameValidator.create(false, AppResourceRepository.getAppResources(configuration.getModule(), true), ResourceType.STYLE); String styleTypeString = isTheme ? "theme" : "style"; setTitle("New " + StringUtil.capitalize(styleTypeString)); myStyleNameLabel.setText(String.format("New %1$s name:", styleTypeString)); myParentStyleLabel.setText(String.format("Parent %1$s name:", styleTypeString)); myEmptyStyleValidationText = String.format("You must specify a %1$s name", styleTypeString); myStyleNameTextField.setText(getNewStyleNameSuggestion(defaultParentName, currentThemeName)); final ThemeResolver themeResolver = context.getThemeResolver(); final ImmutableList<String> defaultThemeNames = ThemeEditorUtils.getDefaultThemeNames(themeResolver); myParentStyleComboBox.setRenderer(new StyleListCellRenderer(context, myParentStyleComboBox)); final ParentThemesListModel parentThemesListModel = new ParentThemesListModel(defaultThemeNames, defaultParentName); myParentStyleComboBox.setModel(parentThemesListModel); myParentStyleComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String selectedValue = (String) myParentStyleComboBox.getSelectedItem(); if (ParentThemesListModel.SHOW_ALL_THEMES.equals(selectedValue)) { myParentStyleComboBox.hidePopup(); final ThemeSelectionDialog dialog = new ThemeSelectionDialog(configuration); if (myThemeChangedListener != null) { dialog.setThemeChangedListener(myThemeChangedListener); } dialog.show(); selectedValue = dialog.isOK() ? dialog.getTheme() : null; } if (selectedValue == null) { selectedValue = (String) parentThemesListModel.getElementAt(0); } else if (!defaultThemeNames.contains(selectedValue)) { parentThemesListModel.removeElement(selectedValue); parentThemesListModel.insertElementAt(selectedValue, 0); } myParentStyleComboBox.setSelectedItem(selectedValue); myStyleNameTextField.setText(getNewStyleNameSuggestion(selectedValue, currentThemeName)); if (myThemeChangedListener != null) { myThemeChangedListener.themeChanged(selectedValue); } } }); init(); }
From source file:org.apache.atlas.repository.typestore.GraphBackedTypeStore.java
private void processsAttribute(TypeSystem typeSystem, String typeName, AttributeInfo attribute, TypeVisitor visitor) throws AtlasException { ImmutableList<String> coreTypes = typeSystem.getCoreTypes(); List<IDataType> attrDataTypes = new ArrayList<>(); IDataType attrDataType = attribute.dataType(); switch (attrDataType.getTypeCategory()) { case ARRAY:/* w ww. j a v a2 s. c o m*/ String attrType = TypeUtils.parseAsArrayType(attrDataType.getName()); if (attrType != null) { IDataType elementType = typeSystem.getDataType(IDataType.class, attrType); attrDataTypes.add(elementType); } break; case MAP: String[] attrTypes = TypeUtils.parseAsMapType(attrDataType.getName()); if (attrTypes != null && attrTypes.length > 1) { IDataType keyType = typeSystem.getDataType(IDataType.class, attrTypes[0]); IDataType valueType = typeSystem.getDataType(IDataType.class, attrTypes[1]); attrDataTypes.add(keyType); attrDataTypes.add(valueType); } break; case ENUM: case STRUCT: case CLASS: attrDataTypes.add(attrDataType); break; case PRIMITIVE: //no vertex for primitive type, hence no edge required break; default: throw new IllegalArgumentException( "Attribute cannot reference instances of type : " + attrDataType.getTypeCategory()); } for (IDataType attrType : attrDataTypes) { if (!coreTypes.contains(attrType.getName())) { visitor.visitAttributeDataType(typeName, attribute, attrType); } } }
From source file:com.google.template.soy.passes.HtmlRewritePass.java
public HtmlRewritePass(ImmutableList<String> experimentalFeatures, ErrorReporter errorReporter) { // TODO(lukes): this is currently conditionally enabled for stricthtml to enable testing. // Turn it on unconditionally. this.enabled = experimentalFeatures.contains("stricthtml"); this.errorReporter = errorReporter; }