Remove Google Guava usage (move to Java7)

Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/b8c06e61
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/b8c06e61
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/b8c06e61

Branch: refs/heads/MNG-6352-print-version
Commit: b8c06e61ab73cd9e25a5b2c93d9e5077b2196751
Parents: d925081
Author: Sylwester Lachiewicz <slachiew...@gmail.com>
Authored: Wed Nov 8 22:29:50 2017 +0100
Committer: Hervé Boutemy <hbout...@apache.org>
Committed: Sun Feb 11 11:54:17 2018 +0100

----------------------------------------------------------------------
 .../java/org/apache/maven/DefaultMaven.java     |   8 +-
 .../execution/DefaultMavenExecutionRequest.java |   4 +-
 .../scope/internal/MojoExecutionScope.java      |   6 +-
 .../maven/extension/internal/CoreExports.java   |  10 +-
 .../extension/internal/CoreExtensionEntry.java  |   7 +-
 .../apache/maven/graph/DefaultGraphBuilder.java |  18 +--
 .../maven/lifecycle/DefaultLifecycles.java      |   7 +-
 ...DefaultLifecycleExecutionPlanCalculator.java |   5 +-
 .../maven/project/ProjectModelResolver.java     |  14 +--
 .../session/scope/internal/SessionScope.java    |   3 +-
 .../java/org/apache/maven/cli/MavenCli.java     |   5 +-
 .../org/apache/maven/model/building/Result.java | 109 +++++++++++--------
 12 files changed, 101 insertions(+), 95 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/b8c06e61/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java 
b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
index 7e46ad0..7f052c1 100644
--- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
+++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
@@ -60,8 +60,6 @@ import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.repository.WorkspaceReader;
 import org.eclipse.aether.util.repository.ChainedWorkspaceReader;
 
-import com.google.common.collect.Iterables;
-
 /**
  * @author Jason van Zyl
  */
@@ -222,8 +220,7 @@ public class DefaultMaven
 
         if ( graphResult.hasErrors() )
         {
-            return addExceptionToResult( result, Iterables.toArray( 
graphResult.getProblems(),
-                                                                    
ModelProblem.class )[0].getException() );
+            return addExceptionToResult( result, 
graphResult.getProblems().iterator().next().getException() );
         }
 
         try
@@ -289,8 +286,7 @@ public class DefaultMaven
 
         if ( graphResult.hasErrors() )
         {
-            return addExceptionToResult( result, Iterables.toArray( 
graphResult.getProblems(),
-                                                                    
ModelProblem.class )[0].getException() );
+            return addExceptionToResult( result, 
graphResult.getProblems().iterator().next().getException() );
         }
 
         try

http://git-wip-us.apache.org/repos/asf/maven/blob/b8c06e61/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
----------------------------------------------------------------------
diff --git 
a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
 
b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
index 089a7db..fe558cd 100644
--- 
a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
+++ 
b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
@@ -43,8 +43,6 @@ import org.eclipse.aether.RepositoryCache;
 import org.eclipse.aether.repository.WorkspaceReader;
 import org.eclipse.aether.transfer.TransferListener;
 
-import com.google.common.collect.Maps;
-
 /**
  * @author Jason van Zyl
  */
@@ -1280,7 +1278,7 @@ public class DefaultMavenExecutionRequest
     {
         if ( data == null )
         {
-            data = Maps.newHashMap();
+            data = new HashMap<>();
         }
 
         return data;

http://git-wip-us.apache.org/repos/asf/maven/blob/b8c06e61/maven-core/src/main/java/org/apache/maven/execution/scope/internal/MojoExecutionScope.java
----------------------------------------------------------------------
diff --git 
a/maven-core/src/main/java/org/apache/maven/execution/scope/internal/MojoExecutionScope.java
 
b/maven-core/src/main/java/org/apache/maven/execution/scope/internal/MojoExecutionScope.java
index 168a87f..785877e 100644
--- 
a/maven-core/src/main/java/org/apache/maven/execution/scope/internal/MojoExecutionScope.java
+++ 
b/maven-core/src/main/java/org/apache/maven/execution/scope/internal/MojoExecutionScope.java
@@ -20,6 +20,7 @@ package org.apache.maven.execution.scope.internal;
  */
 
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.IdentityHashMap;
 import java.util.LinkedList;
 import java.util.Map;
@@ -29,7 +30,6 @@ import org.apache.maven.execution.MojoExecutionListener;
 import org.apache.maven.execution.scope.WeakMojoExecutionListener;
 import org.apache.maven.plugin.MojoExecutionException;
 
-import com.google.common.collect.Maps;
 import com.google.inject.Key;
 import com.google.inject.OutOfScopeException;
 import com.google.inject.Provider;
@@ -52,9 +52,9 @@ public class MojoExecutionScope
 
     private static final class ScopeState
     {
-        private final Map<Key<?>, Provider<?>> seeded = Maps.newHashMap();
+        private final Map<Key<?>, Provider<?>> seeded = new HashMap<>();
 
-        private final Map<Key<?>, Object> provided = Maps.newHashMap();
+        private final Map<Key<?>, Object> provided = new HashMap<>();
     }
 
     private final ThreadLocal<LinkedList<ScopeState>> values = new 
ThreadLocal<>();

http://git-wip-us.apache.org/repos/asf/maven/blob/b8c06e61/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java
----------------------------------------------------------------------
diff --git 
a/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java 
b/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java
index e253e9f..331617c 100644
--- 
a/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java
+++ 
b/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java
@@ -19,15 +19,15 @@ package org.apache.maven.extension.internal;
  * under the License.
  */
 
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
 
 import org.codehaus.plexus.classworlds.realm.ClassRealm;
 
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-
 /**
  * Provides information about artifacts (identified by groupId:artifactId 
string key) and classpath elements exported by
  * Maven core itself and loaded Maven core extensions.
@@ -52,8 +52,8 @@ public class CoreExports
         {
             packages.put( pkg, realm );
         }
-        this.artifacts = ImmutableSet.copyOf( exportedArtifacts );
-        this.packages = ImmutableMap.copyOf( packages );
+        this.artifacts = Collections.unmodifiableSet( new HashSet<>( 
exportedArtifacts ) );
+        this.packages = Collections.unmodifiableMap( new HashMap<>( packages ) 
);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/maven/blob/b8c06e61/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExtensionEntry.java
----------------------------------------------------------------------
diff --git 
a/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExtensionEntry.java
 
b/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExtensionEntry.java
index ffac1d3..50220f6 100644
--- 
a/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExtensionEntry.java
+++ 
b/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExtensionEntry.java
@@ -19,7 +19,6 @@ package org.apache.maven.extension.internal;
  * under the License.
  */
 
-import com.google.common.collect.ImmutableSet;
 import org.apache.maven.project.ExtensionDescriptor;
 import org.apache.maven.project.ExtensionDescriptorBuilder;
 import org.codehaus.plexus.classworlds.realm.ClassRealm;
@@ -29,7 +28,9 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.Set;
 
@@ -50,8 +51,8 @@ public class CoreExtensionEntry
     public CoreExtensionEntry( ClassRealm realm, Collection<String> artifacts, 
Collection<String> packages )
     {
         this.realm = realm;
-        this.artifacts = ImmutableSet.copyOf( artifacts );
-        this.packages = ImmutableSet.copyOf( packages );
+        this.artifacts = Collections.unmodifiableSet( new HashSet<>( artifacts 
) );
+        this.packages = Collections.unmodifiableSet( new HashSet<>( packages ) 
);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/maven/blob/b8c06e61/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
----------------------------------------------------------------------
diff --git 
a/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java 
b/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
index 701e7c5..ec72e8d 100644
--- a/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
@@ -23,12 +23,12 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 
-import com.google.common.collect.Lists;
 import org.apache.maven.DefaultMaven;
 import org.apache.maven.MavenExecutionException;
 import org.apache.maven.ProjectCycleException;
@@ -85,23 +85,17 @@ public class DefaultGraphBuilder
 
             return result;
         }
-        catch ( final ProjectBuildingException e )
+        catch ( final ProjectBuildingException | DuplicateProjectException | 
MavenExecutionException e )
         {
-            return Result.error( Lists.newArrayList( new DefaultModelProblem( 
null, null, null, null, 0, 0, e ) ) );
+            return Result.error( Collections.singletonList
+                    ( new DefaultModelProblem ( null, null, null, null, 0, 0, 
e ) ) );
         }
         catch ( final CycleDetectedException e )
         {
             String message = "The projects in the reactor contain a cyclic 
reference: " + e.getMessage();
             ProjectCycleException error = new ProjectCycleException( message, 
e );
-            return Result.error( Lists.newArrayList( new DefaultModelProblem( 
null, null, null, null, 0, 0, error ) ) );
-        }
-        catch ( final DuplicateProjectException e )
-        {
-            return Result.error( Lists.newArrayList( new DefaultModelProblem( 
null, null, null, null, 0, 0, e ) ) );
-        }
-        catch ( final MavenExecutionException e )
-        {
-            return Result.error( Lists.newArrayList( new DefaultModelProblem( 
null, null, null, null, 0, 0, e ) ) );
+            return Result.error( Collections.singletonList(
+                    new DefaultModelProblem( null, null, null, null, 0, 0, 
error ) ) );
         }
     }
 

http://git-wip-us.apache.org/repos/asf/maven/blob/b8c06e61/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java
----------------------------------------------------------------------
diff --git 
a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java 
b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java
index 8186a39..a7d9fac 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java
@@ -24,8 +24,6 @@ import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.util.StringUtils;
 
-import com.google.common.base.Preconditions;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -122,7 +120,10 @@ public class DefaultLifecycles
         for ( String name : lifecycleNames )
         {
             Lifecycle lifecycle = lifecycles.get( name );
-            Preconditions.checkNotNull( "A lifecycle must have an id.", 
lifecycle.getId() );
+            if ( lifecycle.getId() == null )
+            {
+                throw new NullPointerException( "A lifecycle must have an id." 
);
+            }
             result.add( lifecycle );
         }
 

http://git-wip-us.apache.org/repos/asf/maven/blob/b8c06e61/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java
----------------------------------------------------------------------
diff --git 
a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java
 
b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java
index 1e81b18..ef60c4e 100644
--- 
a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java
+++ 
b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java
@@ -59,7 +59,6 @@ import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
-import com.google.common.collect.ImmutableMap;
 
 /**
  * <strong>NOTE:</strong> This class is not part of any public api and can be 
changed or deleted without prior notice.
@@ -111,8 +110,8 @@ public class DefaultLifecycleExecutionPlanCalculator
         this.defaultLifeCycles = defaultLifeCycles;
         this.mojoDescriptorCreator = mojoDescriptorCreator;
         this.lifecyclePluginResolver = lifecyclePluginResolver;
-        this.mojoExecutionConfigurators =
-            ImmutableMap.of( "default", (MojoExecutionConfigurator) new 
DefaultMojoExecutionConfigurator() );
+        this.mojoExecutionConfigurators = Collections.singletonMap(
+             "default", (MojoExecutionConfigurator) new 
DefaultMojoExecutionConfigurator() );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/maven/blob/b8c06e61/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
----------------------------------------------------------------------
diff --git 
a/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java 
b/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
index 3a31d33..2b3108a 100644
--- 
a/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
+++ 
b/maven-core/src/main/java/org/apache/maven/project/ProjectModelResolver.java
@@ -23,11 +23,10 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Parent;
 import org.apache.maven.model.Repository;
@@ -157,14 +156,15 @@ public class ProjectModelResolver
 
     private static void removeMatchingRepository( Iterable<RemoteRepository> 
repositories, final String id )
     {
-        Iterables.removeIf( repositories, new Predicate<RemoteRepository>()
+        Iterator iterator = repositories.iterator( );
+        while ( iterator.hasNext() )
         {
-            @Override
-            public boolean apply( RemoteRepository remoteRepository )
+            RemoteRepository next =  ( RemoteRepository ) iterator.next();
+            if ( next.getId().equals( id ) )
             {
-                return remoteRepository.getId().equals( id );
+                iterator.remove();
             }
-        } );
+        }
     }
 
     public ModelResolver newCopy()

http://git-wip-us.apache.org/repos/asf/maven/blob/b8c06e61/maven-core/src/main/java/org/apache/maven/session/scope/internal/SessionScope.java
----------------------------------------------------------------------
diff --git 
a/maven-core/src/main/java/org/apache/maven/session/scope/internal/SessionScope.java
 
b/maven-core/src/main/java/org/apache/maven/session/scope/internal/SessionScope.java
index e57a19c..ac423bc 100644
--- 
a/maven-core/src/main/java/org/apache/maven/session/scope/internal/SessionScope.java
+++ 
b/maven-core/src/main/java/org/apache/maven/session/scope/internal/SessionScope.java
@@ -24,7 +24,6 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.Map;
 
-import com.google.common.collect.ImmutableMap;
 import com.google.inject.Key;
 import com.google.inject.OutOfScopeException;
 import com.google.inject.Provider;
@@ -46,7 +45,7 @@ public class SessionScope
 
         Memento( final Map<Key<?>, Provider<?>> seeded )
         {
-            this.seeded = ImmutableMap.copyOf( seeded );
+            this.seeded = Collections.unmodifiableMap( new HashMap<>( seeded ) 
);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/maven/blob/b8c06e61/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java 
b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
index 4fac2ad..f254c58 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -19,8 +19,6 @@ package org.apache.maven.cli;
  * under the License.
  */
 
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
 import com.google.inject.AbstractModule;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.Option;
@@ -101,6 +99,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
+import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -378,7 +377,7 @@ public class MavenCli
 
             if ( configFile.isFile() )
             {
-                for ( String arg : Files.toString( configFile, Charsets.UTF_8 
).split( "\\s+" ) )
+                for ( String arg : new String( Files.readAllBytes( 
configFile.toPath() ) ).split( "\\s+" ) )
                 {
                     if ( !arg.isEmpty() )
                     {

http://git-wip-us.apache.org/repos/asf/maven/blob/b8c06e61/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java
----------------------------------------------------------------------
diff --git 
a/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java 
b/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java
index c9d5f68..df0c797 100644
--- 
a/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java
+++ 
b/maven-model-builder/src/main/java/org/apache/maven/model/building/Result.java
@@ -19,23 +19,14 @@ package org.apache.maven.model.building;
  * under the License.
  */
 
-import static com.google.common.base.Predicates.in;
-import static com.google.common.collect.Iterables.any;
-import static com.google.common.collect.Iterables.concat;
-import static com.google.common.collect.Iterables.transform;
 import static java.util.Collections.singleton;
-import static java.util.EnumSet.of;
 import static org.apache.maven.model.building.ModelProblem.Severity.ERROR;
 import static org.apache.maven.model.building.ModelProblem.Severity.FATAL;
 
-import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
-
-import org.apache.maven.model.building.ModelProblem.Severity;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Iterables;
+import java.util.List;
 
 /**
  * There are various forms of results that are represented by this class:
@@ -83,7 +74,17 @@ public class Result<T>
      */
     public static <T> Result<T> success( T model, Result<?>... results )
     {
-        return success( model, Iterables.concat( Iterables.transform( 
Arrays.asList( results ), GET_PROBLEMS ) ) );
+        final List<ModelProblem> problemsList = new ArrayList<>();
+
+        for ( Result<?> result1 : results )
+        {
+            for ( ModelProblem modelProblem : result1.getProblems() )
+            {
+                problemsList.add( modelProblem );
+            }
+        }
+
+        return success( model, problemsList );
     }
 
     /**
@@ -108,7 +109,17 @@ public class Result<T>
 
     public static <T> Result<T> error( Result<?>... results )
     {
-        return error( Iterables.concat( Iterables.transform( Arrays.asList( 
results ), GET_PROBLEMS ) ) );
+        final List<ModelProblem> problemsList = new ArrayList<>( );
+
+        for ( Result<?> result1 : results )
+        {
+            for ( ModelProblem modelProblem : result1.getProblems( ) )
+            {
+                problemsList.add( modelProblem );
+            }
+        }
+
+        return error( problemsList );
     }
 
     /**
@@ -153,13 +164,30 @@ public class Result<T>
      */
     public static <T> Result<T> addProblems( Result<T> result, Iterable<? 
extends ModelProblem> problems )
     {
-        return new Result<>( result.hasErrors() || hasErrors( problems ), 
result.get(), concat( result.getProblems(),
-                                                                               
                  problems ) );
+        Collection<ModelProblem> list = new ArrayList<>();
+        for ( ModelProblem item : problems )
+        {
+            list.add( item );
+        }
+        for ( ModelProblem item : result.getProblems() )
+        {
+            list.add( item );
+        }
+        return new Result<>( result.hasErrors() || hasErrors( problems ), 
result.get(), list );
     }
 
     public static <T> Result<T> addProblems( Result<T> result, Result<?>... 
results )
     {
-        return addProblems( result, Iterables.concat( Iterables.transform( 
Arrays.asList( results ), GET_PROBLEMS ) ) );
+        final List<ModelProblem> problemsList = new ArrayList<>();
+
+        for ( Result<?> result1 : results )
+        {
+            for ( ModelProblem modelProblem : result1.getProblems( ) )
+            {
+                problemsList.add( modelProblem );
+            }
+        }
+        return addProblems( result, problemsList );
     }
 
     /**
@@ -169,37 +197,38 @@ public class Result<T>
      */
     public static <T> Result<Iterable<T>> newResultSet( Iterable<? extends 
Result<? extends T>> results )
     {
-        final boolean hasErrors = any( transform( results, new 
Function<Result<?>, Boolean>()
+        boolean hasErrors = false;
+        List<T> modelsList = new ArrayList<>();
+        List<ModelProblem> problemsList = new ArrayList<>();
+
+        for ( Result<? extends T> result : results )
         {
-            @Override
-            public Boolean apply( Result<?> input )
+            modelsList.add( result.get() );
+
+            for ( ModelProblem modelProblem : result.getProblems() )
             {
-                return input.hasErrors();
+                problemsList.add( modelProblem );
             }
-        } ), Predicates.equalTo( true ) );
-        final Iterable<T> models = transform( results, new Function<Result<? 
extends T>, T>()
-        {
-            @Override
-            public T apply( Result<? extends T> input )
+
+            if ( result.hasErrors() )
             {
-                return input.get();
+                hasErrors = true;
             }
-        } );
-        final Iterable<ModelProblem> problems = concat( transform( results, 
GET_PROBLEMS ) );
-        return new Result<>( hasErrors, models, problems );
+        }
+        return new Result<>( hasErrors, ( Iterable<T> ) modelsList, 
problemsList );
     }
 
     // helper to determine if problems contain error
     private static boolean hasErrors( Iterable<? extends ModelProblem> 
problems )
     {
-        return any( transform( problems, new Function<ModelProblem, Severity>()
+        for ( ModelProblem input : problems )
         {
-            @Override
-            public Severity apply( ModelProblem input )
+            if ( input.getSeverity().equals( ERROR ) || 
input.getSeverity().equals( FATAL ) )
             {
-                return input.getSeverity();
+                return true;
             }
-        } ), in( of( ERROR, FATAL ) ) );
+        }
+        return false;
     }
 
     /**
@@ -233,14 +262,4 @@ public class Result<T>
     {
         return errors;
     }
-
-    private static final Function<Result<?>, Iterable<? extends ModelProblem>> 
GET_PROBLEMS =
-        new Function<Result<?>, Iterable<? extends ModelProblem>>()
-        {
-            @Override
-            public Iterable<? extends ModelProblem> apply( Result<?> input )
-            {
-                return input.getProblems();
-            }
-        };
 }
\ No newline at end of file

Reply via email to