Search in sources :

Example 86 with Predicate

use of java.util.function.Predicate in project archiva by apache.

the class Maven2RepositoryStorage method readArtifactsMetadata.

@Override
public Collection<ArtifactMetadata> readArtifactsMetadata(ReadMetadataRequest readMetadataRequest) throws RepositoryStorageRuntimeException {
    Path dir = pathTranslator.toFile(getRepositoryBasedir(readMetadataRequest.getRepositoryId()), readMetadataRequest.getNamespace(), readMetadataRequest.getProjectId(), readMetadataRequest.getProjectVersion());
    if (!(Files.exists(dir) && Files.isDirectory(dir))) {
        return Collections.emptyList();
    }
    // all files that are not metadata and not a checksum / signature are considered artifacts
    final Predicate<Path> dFilter = new ArtifactDirectoryFilter(readMetadataRequest.getFilter());
    try (Stream<Path> stream = Files.list(dir)) {
        // Returns a map TRUE -> (success values), FALSE -> (Exceptions)
        Map<Boolean, List<Try<ArtifactMetadata>>> result = stream.filter(dFilter).map(path -> {
            try {
                return Try.success(getArtifactFromFile(readMetadataRequest.getRepositoryId(), readMetadataRequest.getNamespace(), readMetadataRequest.getProjectId(), readMetadataRequest.getProjectVersion(), path));
            } catch (Exception e) {
                LOGGER.debug("Could not create metadata for {}:  {}", path, e.getMessage(), e);
                return Try.<ArtifactMetadata>failure(e);
            }
        }).collect(Collectors.groupingBy(Try::isSuccess));
        if (result.containsKey(Boolean.FALSE) && result.get(Boolean.FALSE).size() > 0 && (!result.containsKey(Boolean.TRUE) || result.get(Boolean.TRUE).size() == 0)) {
            LOGGER.error("Could not get artifact metadata. Directory: {}. Number of errors {}.", dir, result.get(Boolean.FALSE).size());
            Try<ArtifactMetadata> failure = result.get(Boolean.FALSE).get(0);
            LOGGER.error("Sample exception {}", failure.getError().getMessage(), failure.getError());
            throw new RepositoryStorageRuntimeException(readMetadataRequest.getRepositoryId(), "Could not retrieve metadata of the files");
        } else {
            if (!result.containsKey(Boolean.TRUE) || result.get(Boolean.TRUE) == null) {
                return Collections.emptyList();
            }
            return result.get(Boolean.TRUE).stream().map(tr -> tr.get()).collect(Collectors.toList());
        }
    } catch (IOException e) {
        LOGGER.error("Could not read directory {}: {}", dir, e.getMessage(), e);
    }
    return Collections.emptyList();
}
Also used : Path(java.nio.file.Path) StringUtils(org.apache.commons.lang.StringUtils) NoSuchFileException(java.nio.file.NoSuchFileException) Arrays(java.util.Arrays) ArchivaRepositoryMetadata(org.apache.archiva.model.ArchivaRepositoryMetadata) Date(java.util.Date) RepositoryStorageRuntimeException(org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException) LoggerFactory(org.slf4j.LoggerFactory) RepositoryProxyConnectors(org.apache.archiva.proxy.model.RepositoryProxyConnectors) DefaultModelBuilderFactory(org.apache.maven.model.building.DefaultModelBuilderFactory) XMLException(org.apache.archiva.xml.XMLException) RepositoryProblemFacet(org.apache.archiva.metadata.model.facets.RepositoryProblemFacet) ReleaseScheme(org.apache.archiva.repository.ReleaseScheme) NetworkProxyAdmin(org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin) ModelBuilder(org.apache.maven.model.building.ModelBuilder) PathParser(org.apache.archiva.repository.content.PathParser) Map(java.util.Map) ProjectMetadata(org.apache.archiva.metadata.model.ProjectMetadata) Path(java.nio.file.Path) ProxyConnectorAdmin(org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin) Try(org.apache.archiva.common.Try) ArtifactMetadata(org.apache.archiva.metadata.model.ArtifactMetadata) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) Predicate(java.util.function.Predicate) Collection(java.util.Collection) RepositoryRegistry(org.apache.archiva.repository.RepositoryRegistry) ProxyDownloadException(org.apache.archiva.policies.ProxyDownloadException) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector) Filter(org.apache.archiva.metadata.repository.filter.Filter) Reader(java.io.Reader) Collectors(java.util.stream.Collectors) Scm(org.apache.maven.model.Scm) FileNotFoundException(java.io.FileNotFoundException) ManagedRepository(org.apache.archiva.repository.ManagedRepository) Relocation(org.apache.maven.model.Relocation) Organization(org.apache.maven.model.Organization) List(java.util.List) DistributionManagement(org.apache.maven.model.DistributionManagement) Stream(java.util.stream.Stream) ReadMetadataRequest(org.apache.archiva.metadata.repository.storage.ReadMetadataRequest) ModelBuildingRequest(org.apache.maven.model.building.ModelBuildingRequest) PostConstruct(javax.annotation.PostConstruct) ArtifactReference(org.apache.archiva.model.ArtifactReference) MavenXpp3Reader(org.apache.maven.model.io.xpp3.MavenXpp3Reader) Model(org.apache.maven.model.Model) RepositoryStorageMetadataNotFoundException(org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException) CiManagement(org.apache.maven.model.CiManagement) NetworkProxy(org.apache.archiva.admin.model.beans.NetworkProxy) RepositoryPathTranslator(org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator) RelocationException(org.apache.archiva.metadata.repository.storage.RelocationException) Dependency(org.apache.maven.model.Dependency) HashMap(java.util.HashMap) WagonFactory(org.apache.archiva.proxy.common.WagonFactory) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) RemoteRepository(org.apache.archiva.repository.RemoteRepository) Charset(java.nio.charset.Charset) Service(org.springframework.stereotype.Service) ChecksumAlgorithm(org.apache.archiva.checksum.ChecksumAlgorithm) MavenMetadataReader(org.apache.archiva.maven2.metadata.MavenMetadataReader) Named(javax.inject.Named) LayoutException(org.apache.archiva.repository.LayoutException) IssueManagement(org.apache.maven.model.IssueManagement) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) SnapshotVersion(org.apache.archiva.model.SnapshotVersion) Logger(org.slf4j.Logger) Files(java.nio.file.Files) ModelBuildingException(org.apache.maven.model.building.ModelBuildingException) VersionUtil(org.apache.archiva.common.utils.VersionUtil) IOException(java.io.IOException) License(org.apache.maven.model.License) ApplicationContext(org.springframework.context.ApplicationContext) ChecksummedFile(org.apache.archiva.checksum.ChecksummedFile) ModelProblem(org.apache.maven.model.building.ModelProblem) RepositoryStorageMetadataInvalidException(org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException) Paths(java.nio.file.Paths) DefaultModelBuildingRequest(org.apache.maven.model.building.DefaultModelBuildingRequest) MailingList(org.apache.maven.model.MailingList) Collections(java.util.Collections) RepositoryStorage(org.apache.archiva.metadata.repository.storage.RepositoryStorage) ArrayUtils(org.apache.commons.lang.ArrayUtils) RepositoryStorageRuntimeException(org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException) IOException(java.io.IOException) NoSuchFileException(java.nio.file.NoSuchFileException) RepositoryStorageRuntimeException(org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException) XMLException(org.apache.archiva.xml.XMLException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) ProxyDownloadException(org.apache.archiva.policies.ProxyDownloadException) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) FileNotFoundException(java.io.FileNotFoundException) RepositoryStorageMetadataNotFoundException(org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException) RelocationException(org.apache.archiva.metadata.repository.storage.RelocationException) LayoutException(org.apache.archiva.repository.LayoutException) ModelBuildingException(org.apache.maven.model.building.ModelBuildingException) IOException(java.io.IOException) RepositoryStorageMetadataInvalidException(org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException) List(java.util.List) ArrayList(java.util.ArrayList) MailingList(org.apache.maven.model.MailingList) ArtifactMetadata(org.apache.archiva.metadata.model.ArtifactMetadata)

Example 87 with Predicate

use of java.util.function.Predicate in project archiva by apache.

the class Maven2RepositoryStorage method listProjects.

@Override
public Collection<String> listProjects(String repoId, String namespace, Filter<String> filter) throws RepositoryStorageRuntimeException {
    Path dir = pathTranslator.toFile(getRepositoryBasedir(repoId), namespace);
    if (!(Files.exists(dir) && Files.isDirectory(dir))) {
        return Collections.emptyList();
    }
    // scan all directories in the namespace, and only include those that are known to be projects
    final Predicate<Path> dFilter = new DirectoryFilter(filter);
    try (Stream<Path> stream = Files.list(dir)) {
        return stream.filter(dFilter).filter(path -> isProject(path, filter)).map(path -> path.getFileName().toString()).sorted().collect(Collectors.toList());
    } catch (IOException e) {
        LOGGER.error("Could not read directory {}: {}", dir, e.getMessage(), e);
        return Collections.emptyList();
    }
}
Also used : Path(java.nio.file.Path) StringUtils(org.apache.commons.lang.StringUtils) NoSuchFileException(java.nio.file.NoSuchFileException) Arrays(java.util.Arrays) ArchivaRepositoryMetadata(org.apache.archiva.model.ArchivaRepositoryMetadata) Date(java.util.Date) RepositoryStorageRuntimeException(org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException) LoggerFactory(org.slf4j.LoggerFactory) RepositoryProxyConnectors(org.apache.archiva.proxy.model.RepositoryProxyConnectors) DefaultModelBuilderFactory(org.apache.maven.model.building.DefaultModelBuilderFactory) XMLException(org.apache.archiva.xml.XMLException) RepositoryProblemFacet(org.apache.archiva.metadata.model.facets.RepositoryProblemFacet) ReleaseScheme(org.apache.archiva.repository.ReleaseScheme) NetworkProxyAdmin(org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin) ModelBuilder(org.apache.maven.model.building.ModelBuilder) PathParser(org.apache.archiva.repository.content.PathParser) Map(java.util.Map) ProjectMetadata(org.apache.archiva.metadata.model.ProjectMetadata) Path(java.nio.file.Path) ProxyConnectorAdmin(org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin) Try(org.apache.archiva.common.Try) ArtifactMetadata(org.apache.archiva.metadata.model.ArtifactMetadata) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) Predicate(java.util.function.Predicate) Collection(java.util.Collection) RepositoryRegistry(org.apache.archiva.repository.RepositoryRegistry) ProxyDownloadException(org.apache.archiva.policies.ProxyDownloadException) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector) Filter(org.apache.archiva.metadata.repository.filter.Filter) Reader(java.io.Reader) Collectors(java.util.stream.Collectors) Scm(org.apache.maven.model.Scm) FileNotFoundException(java.io.FileNotFoundException) ManagedRepository(org.apache.archiva.repository.ManagedRepository) Relocation(org.apache.maven.model.Relocation) Organization(org.apache.maven.model.Organization) List(java.util.List) DistributionManagement(org.apache.maven.model.DistributionManagement) Stream(java.util.stream.Stream) ReadMetadataRequest(org.apache.archiva.metadata.repository.storage.ReadMetadataRequest) ModelBuildingRequest(org.apache.maven.model.building.ModelBuildingRequest) PostConstruct(javax.annotation.PostConstruct) ArtifactReference(org.apache.archiva.model.ArtifactReference) MavenXpp3Reader(org.apache.maven.model.io.xpp3.MavenXpp3Reader) Model(org.apache.maven.model.Model) RepositoryStorageMetadataNotFoundException(org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException) CiManagement(org.apache.maven.model.CiManagement) NetworkProxy(org.apache.archiva.admin.model.beans.NetworkProxy) RepositoryPathTranslator(org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator) RelocationException(org.apache.archiva.metadata.repository.storage.RelocationException) Dependency(org.apache.maven.model.Dependency) HashMap(java.util.HashMap) WagonFactory(org.apache.archiva.proxy.common.WagonFactory) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) RemoteRepository(org.apache.archiva.repository.RemoteRepository) Charset(java.nio.charset.Charset) Service(org.springframework.stereotype.Service) ChecksumAlgorithm(org.apache.archiva.checksum.ChecksumAlgorithm) MavenMetadataReader(org.apache.archiva.maven2.metadata.MavenMetadataReader) Named(javax.inject.Named) LayoutException(org.apache.archiva.repository.LayoutException) IssueManagement(org.apache.maven.model.IssueManagement) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) SnapshotVersion(org.apache.archiva.model.SnapshotVersion) Logger(org.slf4j.Logger) Files(java.nio.file.Files) ModelBuildingException(org.apache.maven.model.building.ModelBuildingException) VersionUtil(org.apache.archiva.common.utils.VersionUtil) IOException(java.io.IOException) License(org.apache.maven.model.License) ApplicationContext(org.springframework.context.ApplicationContext) ChecksummedFile(org.apache.archiva.checksum.ChecksummedFile) ModelProblem(org.apache.maven.model.building.ModelProblem) RepositoryStorageMetadataInvalidException(org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException) Paths(java.nio.file.Paths) DefaultModelBuildingRequest(org.apache.maven.model.building.DefaultModelBuildingRequest) MailingList(org.apache.maven.model.MailingList) Collections(java.util.Collections) RepositoryStorage(org.apache.archiva.metadata.repository.storage.RepositoryStorage) ArrayUtils(org.apache.commons.lang.ArrayUtils) IOException(java.io.IOException)

Example 88 with Predicate

use of java.util.function.Predicate in project jackrabbit-oak by apache.

the class MongoDocumentTraverser method getAllDocuments.

public <T extends Document> CloseableIterable<T> getAllDocuments(Collection<T> collection, Predicate<String> filter) {
    if (!disableReadOnlyCheck) {
        checkState(mongoStore.isReadOnly(), "Traverser can only be used with readOnly store");
    }
    MongoCollection<BasicDBObject> dbCollection = mongoStore.getDBCollection(collection);
    // TODO This may lead to reads being routed to secondary depending on MongoURI
    // So caller must ensure that its safe to read from secondary
    Iterable<BasicDBObject> cursor = dbCollection.withReadPreference(mongoStore.getConfiguredReadPreference(collection)).find();
    CloseableIterable<BasicDBObject> closeableCursor = CloseableIterable.wrap(cursor);
    cursor = closeableCursor;
    @SuppressWarnings("Guava") Iterable<T> result = FluentIterable.from(cursor).filter(o -> filter.test((String) o.get(Document.ID))).transform(o -> {
        T doc = mongoStore.convertFromDBObject(collection, o);
        // TODO Review the cache update approach where tracker has to track *all* docs
        if (collection == Collection.NODES) {
            NodeDocument nodeDoc = (NodeDocument) doc;
            getNodeDocCache().put(nodeDoc);
        }
        return doc;
    });
    return CloseableIterable.wrap(result, closeableCursor);
}
Also used : Collection(org.apache.jackrabbit.oak.plugins.document.Collection) CloseableIterable(org.apache.jackrabbit.oak.plugins.document.util.CloseableIterable) MongoCollection(com.mongodb.client.MongoCollection) FluentIterable(com.google.common.collect.FluentIterable) Predicate(java.util.function.Predicate) Document(org.apache.jackrabbit.oak.plugins.document.Document) BasicDBObject(com.mongodb.BasicDBObject) NodeDocumentCache(org.apache.jackrabbit.oak.plugins.document.cache.NodeDocumentCache) NodeDocument(org.apache.jackrabbit.oak.plugins.document.NodeDocument) Preconditions.checkState(com.google.common.base.Preconditions.checkState) BasicDBObject(com.mongodb.BasicDBObject) NodeDocument(org.apache.jackrabbit.oak.plugins.document.NodeDocument)

Example 89 with Predicate

use of java.util.function.Predicate in project sonar-java by SonarSource.

the class BytecodeCFGBuilderTest method all_opcodes_should_be_visited.

@Test
public void all_opcodes_should_be_visited() throws Exception {
    Instructions ins = new Instructions();
    Predicate<Integer> filterReturnAndThrow = opcode -> !((Opcodes.IRETURN <= opcode && opcode <= Opcodes.RETURN) || opcode == Opcodes.ATHROW);
    NO_OPERAND_INSN.stream().filter(filterReturnAndThrow).forEach(ins::visitInsn);
    INT_INSN.forEach(i -> ins.visitIntInsn(i, 0));
    VAR_INSN.forEach(i -> ins.visitVarInsn(i, 0));
    TYPE_INSN.forEach(i -> ins.visitTypeInsn(i, "java/lang/Object"));
    FIELD_INSN.forEach(i -> ins.visitFieldInsn(i, "java/lang/Object", "foo", "D(D)"));
    METHOD_INSN.forEach(i -> ins.visitMethodInsn(i, "java/lang/Object", "foo", "()V", i == INVOKEINTERFACE));
    JUMP_INSN.forEach(i -> {
        Label jumpLabel = new Label();
        ins.visitJumpInsn(i, jumpLabel);
        ins.visitLabel(jumpLabel);
    });
    ins.visitLdcInsn("a");
    ins.visitIincInsn(0, 1);
    Handle handle = new Handle(H_INVOKESTATIC, "", "", "()V", false);
    ins.visitInvokeDynamicInsn("sleep", "()V", handle);
    ins.visitLookupSwitchInsn(new Label(), new int[] {}, new Label[] {});
    ins.visitMultiANewArrayInsn("B", 1);
    Label l0 = new Label();
    Label dflt = new Label();
    Label case0 = new Label();
    ins.visitTableSwitchInsn(0, 1, dflt, case0);
    ins.visitLabel(dflt);
    ins.visitInsn(NOP);
    ins.visitLabel(l0);
    ins.visitInsn(NOP);
    BytecodeCFG cfg = ins.cfg();
    Multiset<String> cfgOpcodes = cfgOpcodes(cfg);
    List<String> collect = Instructions.ASM_OPCODES.stream().filter(filterReturnAndThrow).map(op -> Printer.OPCODES[op]).collect(Collectors.toList());
    assertThat(cfgOpcodes).containsAll(collect);
}
Also used : Iterables(com.google.common.collect.Iterables) Arrays(java.util.Arrays) JavaSymbol(org.sonar.java.resolve.JavaSymbol) H_INVOKESTATIC(org.objectweb.asm.Opcodes.H_INVOKESTATIC) Multiset(com.google.common.collect.Multiset) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SETestUtils(org.sonar.java.se.SETestUtils) NO_OPERAND_INSN(org.sonar.java.bytecode.cfg.Instructions.NO_OPERAND_INSN) Label(org.objectweb.asm.Label) CompilationUnitTree(org.sonar.plugins.java.api.tree.CompilationUnitTree) VAR_INSN(org.sonar.java.bytecode.cfg.Instructions.VAR_INSN) MethodNode(org.objectweb.asm.tree.MethodNode) INVOKEINTERFACE(org.objectweb.asm.Opcodes.INVOKEINTERFACE) Lists(com.google.common.collect.Lists) CFGTestData(org.sonar.java.bytecode.cfg.testdata.CFGTestData) HashMultiset(com.google.common.collect.HashMultiset) FIELD_INSN(org.sonar.java.bytecode.cfg.Instructions.FIELD_INSN) JUMP_INSN(org.sonar.java.bytecode.cfg.Instructions.JUMP_INSN) METHOD_INSN(org.sonar.java.bytecode.cfg.Instructions.METHOD_INSN) JavaParser(org.sonar.java.ast.parser.JavaParser) NOP(org.objectweb.asm.Opcodes.NOP) Opcodes(org.objectweb.asm.Opcodes) Predicate(java.util.function.Predicate) SquidClassLoader(org.sonar.java.bytecode.loader.SquidClassLoader) IOException(java.io.IOException) Test(org.junit.Test) TYPE_INSN(org.sonar.java.bytecode.cfg.Instructions.TYPE_INSN) Tree(org.sonar.plugins.java.api.tree.Tree) Collectors(java.util.stream.Collectors) File(java.io.File) Objects(java.util.Objects) Handle(org.objectweb.asm.Handle) List(java.util.List) Stream(java.util.stream.Stream) Rule(org.junit.Rule) LogTester(org.sonar.api.utils.log.LogTester) ClassReader(org.objectweb.asm.ClassReader) Printer(org.objectweb.asm.util.Printer) SemanticModel(org.sonar.java.resolve.SemanticModel) AbstractInsnNode(org.objectweb.asm.tree.AbstractInsnNode) ClassTree(org.sonar.plugins.java.api.tree.ClassTree) JSR(org.objectweb.asm.Opcodes.JSR) ClassNode(org.objectweb.asm.tree.ClassNode) Convert(org.sonar.java.resolve.Convert) INT_INSN(org.sonar.java.bytecode.cfg.Instructions.INT_INSN) Symbol(org.sonar.plugins.java.api.semantic.Symbol) LoggerLevel(org.sonar.api.utils.log.LoggerLevel) MethodTree(org.sonar.plugins.java.api.tree.MethodTree) Label(org.objectweb.asm.Label) Handle(org.objectweb.asm.Handle) Test(org.junit.Test)

Example 90 with Predicate

use of java.util.function.Predicate in project n4js by eclipse.

the class ScriptApiTracker method computeMissingApiMethods.

/**
 * Looking for at.ProvidesDefaultImplementation on Methods. Normal method declarations are not taken into account,
 * since they would not be executed on the interface level.
 *
 * Beware: also the inheritance in the original API will be taken into account since compiled client code will link
 * against that.
 *
 * @param type
 *            type to search for apis.
 * @return List of {@link VirtualApiTMethod}
 */
public List<TMethod> computeMissingApiMethods(TInterface type, EObject context) {
    Optional<ProjectComparisonAdapter> optAdapt = firstProjectComparisonAdapter(context.eResource());
    if (optAdapt.isPresent()) {
        ProjectComparisonAdapter projectComparisonAdapter = optAdapt.get();
        ProjectComparisonEntry compareEntry = projectComparisonAdapter.getEntryFor(EcoreUtil2.getContainerOfType(type, TModule.class));
        ProjectComparisonEntry typeCompare = compareEntry.getChildForElementImpl(type);
        if (typeCompare == null) {
            // are we in a completely missing API implementation (super-interfaces not implemented ?)
            typeCompare = compareEntry.getChildForElementAPI(type);
        }
        if (typeCompare == null) {
            if (logger.isDebugEnabled()) {
                logger.debug(" want to throw new IllegalstateException() --> comparison for implementation not found type=" + type.getTypeAsString() + " in Implementation " + compareEntry.getElementImpl()[0]);
            }
            return emptyList();
        }
        LinkedHashMultimap<TMethod, TInterface> lhmmMehodInterface = LinkedHashMultimap.<TMethod, TInterface>create();
        Predicate<ProjectComparisonEntry> filter = (pce -> pce.getElementAPI() instanceof TMethod);
        filter = filter.and(pce -> pce.getElementImpl()[0] == null).and(pce -> PROVIDES_DEFAULT_IMPLEMENTATION.hasAnnotation((TMethod) pce.getElementAPI()));
        Function<TInterface, Consumer<? super ProjectComparisonEntry>> actionProvider = pivot -> pce -> {
            TMethod method = ((TMethod) pce.getElementAPI());
            lhmmMehodInterface.put(method, pivot);
        };
        if (!checkInterfaceImplementsInterface(type, typeCompare.getElementAPI())) {
            return emptyList();
        }
        // Call the supertype iterations scaffolding:
        interfaceApiSupertypeWalker(filter, actionProvider, projectComparisonAdapter, (TInterface) typeCompare.getElementAPI(), TInterface.class);
        // out in the caller when processing our results...
        return lhmmMehodInterface.keySet().stream().map(m -> new VirtualApiTMethod(m.getName(), TypeUtils.copyPartial(m, TypesPackage.Literals.SYNTAX_RELATED_TELEMENT__AST_ELEMENT))).collect(Collectors.toList());
    }
    return emptyList();
}
Also used : ProjectComparisonEntry(org.eclipse.n4js.compare.ProjectComparisonEntry) Inject(com.google.inject.Inject) TClass(org.eclipse.n4js.ts.types.TClass) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) TSetter(org.eclipse.n4js.ts.types.TSetter) Logger(org.apache.log4j.Logger) TGetterImpl(org.eclipse.n4js.ts.types.impl.TGetterImpl) TMethodImpl(org.eclipse.n4js.ts.types.impl.TMethodImpl) Type(org.eclipse.n4js.ts.types.Type) MemberList(org.eclipse.n4js.ts.types.util.MemberList) N4InterfaceDeclaration(org.eclipse.n4js.n4JS.N4InterfaceDeclaration) TFieldImpl(org.eclipse.n4js.ts.types.impl.TFieldImpl) LinkedHashMultimap(com.google.common.collect.LinkedHashMultimap) Collections.emptyList(java.util.Collections.emptyList) Predicate(java.util.function.Predicate) TField(org.eclipse.n4js.ts.types.TField) EObject(org.eclipse.emf.ecore.EObject) PROVIDES_DEFAULT_IMPLEMENTATION(org.eclipse.n4js.AnnotationDefinition.PROVIDES_DEFAULT_IMPLEMENTATION) PROVIDES_INITIALZER(org.eclipse.n4js.AnnotationDefinition.PROVIDES_INITIALZER) TMethod(org.eclipse.n4js.ts.types.TMethod) Collectors(java.util.stream.Collectors) TGetter(org.eclipse.n4js.ts.types.TGetter) List(java.util.List) Stream(java.util.stream.Stream) TClassifier(org.eclipse.n4js.ts.types.TClassifier) Resource(org.eclipse.emf.ecore.resource.Resource) Optional(java.util.Optional) Pair(org.eclipse.xtext.xbase.lib.Pair) TypesFactory(org.eclipse.n4js.ts.types.TypesFactory) Singleton(com.google.inject.Singleton) HashMap(java.util.HashMap) TypeUtils(org.eclipse.n4js.ts.utils.TypeUtils) AccessorTuple(org.eclipse.n4js.ts.types.util.AccessorTuple) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) TModule(org.eclipse.n4js.ts.types.TModule) TN4Classifier(org.eclipse.n4js.ts.types.TN4Classifier) TInterface(org.eclipse.n4js.ts.types.TInterface) ProjectCompareHelper(org.eclipse.n4js.compare.ProjectCompareHelper) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) TAnnotableElement(org.eclipse.n4js.ts.types.TAnnotableElement) MemberCollector(org.eclipse.n4js.utils.ContainerTypesHelper.MemberCollector) LinkedHashSet(java.util.LinkedHashSet) Iterator(java.util.Iterator) TMember(org.eclipse.n4js.ts.types.TMember) Script(org.eclipse.n4js.n4JS.Script) Consumer(java.util.function.Consumer) TypesPackage(org.eclipse.n4js.ts.types.TypesPackage) AdapterImpl(org.eclipse.emf.common.notify.impl.AdapterImpl) TSetterImpl(org.eclipse.n4js.ts.types.impl.TSetterImpl) Collections(java.util.Collections) TMethod(org.eclipse.n4js.ts.types.TMethod) Consumer(java.util.function.Consumer) TInterface(org.eclipse.n4js.ts.types.TInterface) TModule(org.eclipse.n4js.ts.types.TModule) ProjectComparisonEntry(org.eclipse.n4js.compare.ProjectComparisonEntry)

Aggregations

Predicate (java.util.function.Predicate)589 List (java.util.List)266 ArrayList (java.util.ArrayList)170 Collectors (java.util.stream.Collectors)167 Map (java.util.Map)164 Set (java.util.Set)137 Test (org.junit.Test)133 IOException (java.io.IOException)122 Collections (java.util.Collections)118 Arrays (java.util.Arrays)110 HashMap (java.util.HashMap)105 Collection (java.util.Collection)93 Optional (java.util.Optional)87 HashSet (java.util.HashSet)85 Stream (java.util.stream.Stream)69 Function (java.util.function.Function)61 File (java.io.File)60 Iterator (java.util.Iterator)55 Logger (org.slf4j.Logger)53 LoggerFactory (org.slf4j.LoggerFactory)52