Author: hboutemy
Date: Tue Oct 30 17:20:14 2012
New Revision: 1403786

URL: http://svn.apache.org/viewvc?rev=1403786&view=rev
Log:
code simplification

Modified:
    
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java
    
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java
    
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java

Modified: 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java
URL: 
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java?rev=1403786&r1=1403785&r2=1403786&view=diff
==============================================================================
--- 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java
 (original)
+++ 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java
 Tue Oct 30 17:20:14 2012
@@ -44,42 +44,42 @@ public class JdkVersionProfileActivator
 
     public boolean isActive( Profile profile, ProfileActivationContext 
context, ModelProblemCollector problems )
     {
-        boolean active = false;
-
         Activation activation = profile.getActivation();
 
-        if ( activation != null )
+        if ( activation == null )
         {
-            String jdk = activation.getJdk();
+            return false;
+        }
 
-            if ( jdk != null )
-            {
-                String version = context.getSystemProperties().get( 
"java.version" );
+        String jdk = activation.getJdk();
 
-                if ( version == null || version.length() <= 0 )
-                {
-                    problems.add( new ModelProblemCollectorRequest( 
Severity.ERROR, Version.BASE )
-                            .setMessage( "Failed to determine Java version for 
profile " + profile.getId() )
-                            .setLocation(activation.getLocation( "jdk" ) ) );
-                    return false;
-                }
-
-                if ( jdk.startsWith( "!" ) )
-                {
-                    active = !version.startsWith( jdk.substring( 1 ) );
-                }
-                else if ( isRange( jdk ) )
-                {
-                    active = isInRange( version, getRange( jdk ) );
-                }
-                else
-                {
-                    active = version.startsWith( jdk );
-                }
-            }
+        if ( jdk == null )
+        {
+            return false;
+        }
+
+        String version = context.getSystemProperties().get( "java.version" );
+
+        if ( version == null || version.length() <= 0 )
+        {
+            problems.add( new ModelProblemCollectorRequest( Severity.ERROR, 
Version.BASE )
+                    .setMessage( "Failed to determine Java version for profile 
" + profile.getId() )
+                    .setLocation(activation.getLocation( "jdk" ) ) );
+            return false;
         }
 
-        return active;
+        if ( jdk.startsWith( "!" ) )
+        {
+            return !version.startsWith( jdk.substring( 1 ) );
+        }
+        else if ( isRange( jdk ) )
+        {
+            return isInRange( version, getRange( jdk ) );
+        }
+        else
+        {
+            return version.startsWith( jdk );
+        }
     }
 
     private static boolean isInRange( String value, List<RangeValue> range )

Modified: 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java
URL: 
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java?rev=1403786&r1=1403785&r2=1403786&view=diff
==============================================================================
--- 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java
 (original)
+++ 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java
 Tue Oct 30 17:20:14 2012
@@ -39,35 +39,37 @@ public class OperatingSystemProfileActiv
 
     public boolean isActive( Profile profile, ProfileActivationContext 
context, ModelProblemCollector problems )
     {
-        boolean active = false;
-
         Activation activation = profile.getActivation();
 
-        if ( activation != null )
+        if ( activation == null )
         {
-            ActivationOS os = activation.getOs();
+            return false;
+        }
 
-            if ( os != null )
-            {
-                active = ensureAtLeastOneNonNull( os );
-
-                if ( active && os.getFamily() != null )
-                {
-                    active = determineFamilyMatch( os.getFamily() );
-                }
-                if ( active && os.getName() != null )
-                {
-                    active = determineNameMatch( os.getName() );
-                }
-                if ( active && os.getArch() != null )
-                {
-                    active = determineArchMatch( os.getArch() );
-                }
-                if ( active && os.getVersion() != null )
-                {
-                    active = determineVersionMatch( os.getVersion() );
-                }
-            }
+        ActivationOS os = activation.getOs();
+
+        if ( os == null )
+        {
+            return false;
+        }
+
+        boolean active = ensureAtLeastOneNonNull( os );
+
+        if ( active && os.getFamily() != null )
+        {
+            active = determineFamilyMatch( os.getFamily() );
+        }
+        if ( active && os.getName() != null )
+        {
+            active = determineNameMatch( os.getName() );
+        }
+        if ( active && os.getArch() != null )
+        {
+            active = determineArchMatch( os.getArch() );
+        }
+        if ( active && os.getVersion() != null )
+        {
+            active = determineVersionMatch( os.getVersion() );
         }
 
         return active;
@@ -91,14 +93,7 @@ public class OperatingSystemProfileActiv
 
         boolean result = Os.isVersion( test );
 
-        if ( reverse )
-        {
-            return !result;
-        }
-        else
-        {
-            return result;
-        }
+        return reverse ? !result : result;
     }
 
     private boolean determineArchMatch( String arch )
@@ -114,14 +109,7 @@ public class OperatingSystemProfileActiv
 
         boolean result = Os.isArch( test );
 
-        if ( reverse )
-        {
-            return !result;
-        }
-        else
-        {
-            return result;
-        }
+        return reverse ? !result : result;
     }
 
     private boolean determineNameMatch( String name )
@@ -137,14 +125,7 @@ public class OperatingSystemProfileActiv
 
         boolean result = Os.isName( test );
 
-        if ( reverse )
-        {
-            return !result;
-        }
-        else
-        {
-            return result;
-        }
+        return reverse ? !result : result;
     }
 
     private boolean determineFamilyMatch( String family )
@@ -160,14 +141,7 @@ public class OperatingSystemProfileActiv
 
         boolean result = Os.isFamily( test );
 
-        if ( reverse )
-        {
-            return !result;
-        }
-        else
-        {
-            return result;
-        }
+        return reverse ? !result : result;
     }
 
 }

Modified: 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java
URL: 
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java?rev=1403786&r1=1403785&r2=1403786&view=diff
==============================================================================
--- 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java
 (original)
+++ 
maven/maven-3/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java
 Tue Oct 30 17:20:14 2012
@@ -42,78 +42,64 @@ public class PropertyProfileActivator
 
     public boolean isActive( Profile profile, ProfileActivationContext 
context, ModelProblemCollector problems )
     {
-        boolean active = false;
-
         Activation activation = profile.getActivation();
 
-        if ( activation != null )
+        if ( activation == null )
         {
-            ActivationProperty property = activation.getProperty();
+            return false;
+        }
 
-            if ( property != null )
-            {
-                String name = property.getName();
-                boolean reverseName = false;
+        ActivationProperty property = activation.getProperty();
+
+        if ( property == null )
+        {
+            return false;
+        }
+
+        String name = property.getName();
+        boolean reverseName = false;
+
+        if ( name != null && name.startsWith( "!" ) )
+        {
+            reverseName = true;
+            name = name.substring( 1 );
+        }
+
+        if ( name == null || name.length() <= 0 )
+        {
+            problems.add( new ModelProblemCollectorRequest( Severity.ERROR, 
Version.BASE )
+                    .setMessage( "The property name is required to activate 
the profile " + profile.getId() )
+                    .setLocation( property.getLocation( "" ) ) );
+            return false;
+        }
+
+        String sysValue = context.getUserProperties().get( name );
+        if ( sysValue == null )
+        {
+            sysValue = context.getSystemProperties().get( name );
+        }
 
-                if ( name != null && name.startsWith( "!" ) )
-                {
-                    reverseName = true;
-                    name = name.substring( 1 );
-                }
-
-                if ( name == null || name.length() <= 0 )
-                {
-                    problems.add( new ModelProblemCollectorRequest( 
Severity.ERROR, Version.BASE )
-                            .setMessage( "The property name is required to 
activate the profile " + profile.getId() )
-                            .setLocation( property.getLocation( "" ) ) );
-                    return false;
-                }
-
-                String sysValue = context.getUserProperties().get( name );
-                if ( sysValue == null )
-                {
-                    sysValue = context.getSystemProperties().get( name );
-                }
-
-                String propValue = property.getValue();
-                if ( StringUtils.isNotEmpty( propValue ) )
-                {
-                    boolean reverseValue = false;
-                    if ( propValue.startsWith( "!" ) )
-                    {
-                        reverseValue = true;
-                        propValue = propValue.substring( 1 );
-                    }
-
-                    // we have a value, so it has to match the system value...
-                    boolean result = propValue.equals( sysValue );
-
-                    if ( reverseValue )
-                    {
-                        active = !result;
-                    }
-                    else
-                    {
-                        active = result;
-                    }
-                }
-                else
-                {
-                    boolean result = StringUtils.isNotEmpty( sysValue );
-
-                    if ( reverseName )
-                    {
-                        active = !result;
-                    }
-                    else
-                    {
-                        active = result;
-                    }
-                }
+        String propValue = property.getValue();
+        if ( StringUtils.isNotEmpty( propValue ) )
+        {
+            boolean reverseValue = false;
+            if ( propValue.startsWith( "!" ) )
+            {
+                reverseValue = true;
+                propValue = propValue.substring( 1 );
             }
+
+            // we have a value, so it has to match the system value...
+            boolean result = propValue.equals( sysValue );
+
+            return reverseValue ? !result : result;
         }
+        else
+        {
+            boolean result = StringUtils.isNotEmpty( sysValue );
 
-        return active;
+            return reverseName ? !result : result;
+        }
     }
 
 }


Reply via email to