Example usage for com.google.common.collect Iterables addAll

List of usage examples for com.google.common.collect Iterables addAll

Introduction

In this page you can find the example usage for com.google.common.collect Iterables addAll.

Prototype

public static <T> boolean addAll(Collection<T> addTo, Iterable<? extends T> elementsToAdd) 

Source Link

Document

Adds all elements in iterable to collection .

Usage

From source file:msi.gama.lang.gaml.validation.GamlModelBuilder.java

private static ModelDescription buildModelDescription(final GamlResource r,
        final List<GamlCompilationError> errors) {
    try {// w ww .ja  va 2  s . c om

        // Syntactic errors detected, we cannot build the resource
        if (r.hasErrors()) {
            if (errors != null)
                errors.add(new GamlCompilationError("Syntax errors ", IGamlIssue.GENERAL,
                        r.getContents().get(0), false, false));
            return null;
        } else {
            // We build the description
            final ModelDescription model = r.buildCompleteDescription();
            if (errors != null)
                Iterables.addAll(errors, r.getValidationContext());
            return model;
        }
    } finally {
    }
}

From source file:com.zimbra.soap.mail.type.CalendaringData.java

@Override
public void setCategories(Iterable<String> categories) {
    this.categories.clear();
    if (categories != null) {
        Iterables.addAll(this.categories, categories);
    }//from   ww w .java  2 s  . c  o  m
}

From source file:com.zimbra.soap.admin.message.GetDelegatedAdminConstraintsRequest.java

public void setAttrs(Iterable<NamedElement> attrs) {
    this.attrs.clear();
    if (attrs != null) {
        Iterables.addAll(this.attrs, attrs);
    }/*from  ww w  .  jav  a 2  s . c  om*/
}

From source file:com.zimbra.soap.admin.message.FixCalendarTZRequest.java

public void setFixupRules(Iterable<TZFixupRule> fixupRules) {
    this.fixupRules.clear();
    if (fixupRules != null) {
        Iterables.addAll(this.fixupRules, fixupRules);
    }//  ww  w . j  a  v a 2 s  . c  om
}

From source file:org.xwiki.search.solr.internal.reference.ObjectSolrReferenceResolver.java

@Override
public List<EntityReference> getReferences(EntityReference objectReference) throws SolrIndexerException {
    List<EntityReference> result = new ArrayList<>();

    // Object itself
    result.add(objectReference);/*from   w  w  w .  j  a  v a2 s  . c  o m*/

    // Object properties
    DocumentReference documentReference = new DocumentReference(objectReference.getParent());

    XWikiDocument document;
    try {
        document = getDocument(documentReference);
    } catch (Exception e) {
        throw new SolrIndexerException("Failed to get document for object [" + objectReference + "]", e);
    }

    BaseObject object = document.getXObject(objectReference);
    if (object != null) {
        for (Object field : object.getFieldList()) {
            BaseProperty<ObjectPropertyReference> objectProperty = (BaseProperty<ObjectPropertyReference>) field;

            ObjectPropertyReference objectPropertyReference = objectProperty.getReference();

            try {
                Iterables.addAll(result,
                        this.objectPropertyResolverProvider.get().getReferences(objectPropertyReference));
            } catch (Exception e) {
                this.logger.error(
                        "Failed to resolve references for object property [" + objectPropertyReference + "]",
                        e);
            }
        }
    }

    return result;
}

From source file:org.apache.flex.compiler.internal.targets.JSTarget.java

@Override
public IJSApplication build(Collection<ICompilerProblem> problems) {
    buildStarted();//from  w  w  w . j  a  v  a  2  s .c  o  m
    try {
        Iterable<ICompilerProblem> fatalProblems = getFatalProblems();
        if (!Iterables.isEmpty(fatalProblems)) {
            Iterables.addAll(problems, fatalProblems);
            return null;
        }

        Set<ICompilationUnit> compilationUnitSet = new HashSet<ICompilationUnit>();
        Target.RootedCompilationUnits rootedCompilationUnits = getRootedCompilationUnits();
        Iterables.addAll(problems, rootedCompilationUnits.getProblems());

        compilationUnitSet.addAll(rootedCompilationUnits.getUnits());

        buildAndCollectProblems(compilationUnitSet, problems);

        List<ICompilationUnit> reachableCompilationUnits = project
                .getReachableCompilationUnitsInSWFOrder(rootedCompilationUnits.getUnits());

        IJSApplication application = initializeApplication(reachableCompilationUnits);

        //            ISWF swf = initializeSWF(reachableCompilationUnits);
        //
        //            // make main frame for DoABC tags
        //            final SWFFrame mainFrame = new SWFFrame();
        //            swf.addFrame(mainFrame);
        //
        //            // Add definitions.
        //            for (final ICompilationUnit cu : compilationUnitSet)
        //            {
        //                // ignore externals
        //                if (isLinkageExternal(cu, targetSettings))
        //                    continue;
        //
        //                // ignore any resource bundles
        //                if (cu instanceof ResourceBundleCompilationUnit)
        //                    continue;
        //
        //                // Create a DoABC tag per compilation unit.
        //
        //                // Please add this API to SWFTarget. Thx.
        //                // protected Boolean addToFrame(ICompilationUnit cu, SWFFrame mainFrame) throws InterruptedException
        //                // final boolean tagsAdded = cu.getSWFTagsRequest().get().addToFrame(mainFrame);
        //                final boolean tagsAdded = addToFrame(cu, mainFrame);
        //                if (!tagsAdded)
        //                {
        //                    ICompilerProblem problem = new UnableToBuildSWFTagProblem(cu.getAbsoluteFilename());
        //                    problems.add(problem);
        //                }
        //            }
        //
        //            createLinkReport(problems);

        return application;
    } catch (BuildCanceledException bce) {
        return null;
    } catch (InterruptedException ie) {
        return null;
    } finally {
        buildFinished();
    }
}

From source file:gr.forth.ics.swkm.model2.Inference.java

/**
 * Returns, but does not delete, the redundant triples of a model, as defined in {@link #reduce(Model)}.
 *
 * @param model the model for which to find the redundant triples
 * @return the redundant triples of the specified model
 *//*w ww .  j  a v  a  2 s  .  co  m*/
public static Collection<Triple> findRedundantTriples(Model model) {
    Collection<Triple> triplesToRemove = new ArrayList<Triple>();
    {
        Graph subClassGraph = GraphUtils.classesAndInstancesGraph(model);
        PathFinder pathFinder = ((ModelImpl) model).getLabelManager().areLabelsAvailable()
                ? new LabelingPathFinder(model)
                : null;
        Iterables.addAll(triplesToRemove, reduce(subClassGraph, pathFinder != null ? pathFinder
                : Transitivity.acyclicClosure(subClassGraph, SuccessorSetFactory.intervalBased(subClassGraph)),
                true));
    }

    {
        Graph subPropertyGraph = GraphUtils.propertiesAndInstancesGraph(model);
        PathFinder pathFinder = ((ModelImpl) model).getLabelManager().areLabelsAvailable()
                ? new LabelingPathFinder(model)
                : null;
        Iterables.addAll(triplesToRemove,
                reduce(subPropertyGraph,
                        pathFinder != null ? pathFinder
                                : Transitivity.acyclicClosure(subPropertyGraph,
                                        SuccessorSetFactory.intervalBased(subPropertyGraph)),
                        false));
    }
    return triplesToRemove;
}

From source file:com.ignorelist.kassandra.steam.scraper.JsonApiTagLoader.java

@Override
public GameInfo load(Long gameId, EnumSet<TagType> types) {
    GameInfo gameInfo = new GameInfo();
    gameInfo.setId(gameId);/* w ww .ja v a2s .  c o  m*/
    try {
        InputStream inputStream = cache.get(gameId.toString());
        try {
            final Data gameData = loadAppData(inputStream);
            gameInfo.setName(gameData.getName());
            if (types.contains(TagType.CATEGORY)) {
                Iterables.addAll(gameInfo.getTags().get(TagType.CATEGORY),
                        Iterables.transform(gameData.getCategories(), new Function<Category, String>() {
                            @Override
                            public String apply(Category input) {
                                return input.getDescription();
                            }
                        }));
            }
            if (types.contains(TagType.GENRE)) {
                Iterables.addAll(gameInfo.getTags().get(TagType.GENRE),
                        Iterables.transform(gameData.getGenres(), new Function<Genre, String>() {
                            @Override
                            public String apply(Genre input) {
                                return input.getDescription();
                            }
                        }));
            }
        } catch (IOException ex) {
            Logger.getLogger(JsonApiTagLoader.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            IOUtils.closeQuietly(inputStream);
        }
    } catch (ExecutionException ex) {
        Logger.getLogger(JsonApiTagLoader.class.getName()).log(Level.SEVERE, null, ex);
    }
    return gameInfo;
}

From source file:com.zimbra.soap.account.type.SMIMEPublicCertsStoreSpec.java

public void addStoreTypes(Iterable<String> storeTypes) {
    if (storeTypes != null) {
        Iterables.addAll(this.storeTypes, storeTypes);
    }//from  w ww  . j  a  va 2  s .com
}

From source file:org.gradle.model.internal.core.DefaultNodeInitializerRegistry.java

public ModelTypeInitializationException canNotConstructTypeException(NodeInitializerContext context) {
    Iterable<ModelType<?>> scalars = Iterables.concat(ScalarTypes.TYPES, ScalarTypes.NON_FINAL_TYPES);
    Set<ModelType<?>> constructableTypes = new TreeSet<ModelType<?>>(new Comparator<ModelType<?>>() {
        @Override//  w w w .j  a v a2  s.c om
        public int compare(ModelType<?> o1, ModelType<?> o2) {
            return o1.getDisplayName().compareTo(o2.getDisplayName());
        }
    });
    for (NodeInitializerExtractionStrategy extractor : additionalStrategies) {
        Iterables.addAll(constructableTypes, extractor.supportedTypes());
    }
    return new ModelTypeInitializationException(context, schemaStore, scalars, constructableTypes);
}