polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [3/7] polygene-java git commit: :core:api refine
Date Sun, 14 May 2017 14:33:20 GMT
:core:api refine

- prefer lambdas over anonymous classes
- prefer diamond generics
- remove unnecessary modifiers
- formatting


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

Branch: refs/heads/develop
Commit: f819bfe31f44eb0b5fc1287842550be400bc8178
Parents: 530b6dd
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Sun May 14 16:09:29 2017 +0200
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Sun May 14 16:09:29 2017 +0200

----------------------------------------------------------------------
 .../polygene/api/composite/PropertyMapper.java  | 27 ++---------
 .../polygene/api/identity/HasIdentity.java      |  1 -
 .../polygene/api/property/DefaultValues.java    |  2 +-
 .../polygene/api/service/qualifier/Active.java  |  2 +-
 .../service/qualifier/AnnotationQualifier.java  |  2 +-
 .../api/service/qualifier/Available.java        |  2 +-
 .../api/service/qualifier/HasMetaInfo.java      | 31 ++++++-------
 .../api/service/qualifier/IdentifiedBy.java     |  4 +-
 .../api/service/qualifier/Qualifier.java        |  2 +-
 .../api/service/qualifier/ServiceQualifier.java | 48 ++++----------------
 .../org/apache/polygene/api/util/Classes.java   |  2 +-
 .../runtime/composite/ConstraintsCheck.java     |  2 +-
 12 files changed, 34 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f819bfe3/core/api/src/main/java/org/apache/polygene/api/composite/PropertyMapper.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/composite/PropertyMapper.java
b/core/api/src/main/java/org/apache/polygene/api/composite/PropertyMapper.java
index 09102d0..acff127 100644
--- a/core/api/src/main/java/org/apache/polygene/api/composite/PropertyMapper.java
+++ b/core/api/src/main/java/org/apache/polygene/api/composite/PropertyMapper.java
@@ -549,14 +549,7 @@ public final class PropertyMapper
         {
             final Class arrayType = ( (Class) type ).getComponentType();
             final ArrayList result = new ArrayList();
-            tokenize( value, false, new TokenizerCallback()
-            {
-                @Override
-                public void token( String token )
-                {
-                    result.add( mapToType( composite, arrayType, token ) );
-                }
-            } );
+            tokenize( value, false, token -> result.add( mapToType( composite, arrayType,
token ) ) );
             return result.toArray( (Object[]) Array.newInstance( arrayType, result.size()
) );
         }
     }
@@ -580,14 +573,7 @@ public final class PropertyMapper
         {
             final Type dataType = ( (ParameterizedType) type ).getActualTypeArguments()[
0 ];
             final Collection result = new ArrayList();
-            tokenize( value, false, new TokenizerCallback()
-            {
-                @Override
-                public void token( String token )
-                {
-                    result.add( mapToType( composite, dataType, token ) );
-                }
-            } );
+            tokenize( value, false, token -> result.add( mapToType( composite, dataType,
token ) ) );
             return result;
         }
     }
@@ -601,14 +587,7 @@ public final class PropertyMapper
         {
             final Type dataType = ( (ParameterizedType) type ).getActualTypeArguments()[
0 ];
             final Collection result = new HashSet();
-            tokenize( value, false, new TokenizerCallback()
-            {
-                @Override
-                public void token( String token )
-                {
-                    result.add( mapToType( composite, dataType, token ) );
-                }
-            } );
+            tokenize( value, false, token -> result.add( mapToType( composite, dataType,
token ) ) );
             return result;
         }
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f819bfe3/core/api/src/main/java/org/apache/polygene/api/identity/HasIdentity.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/identity/HasIdentity.java b/core/api/src/main/java/org/apache/polygene/api/identity/HasIdentity.java
index 4e139d1..cbed394 100644
--- a/core/api/src/main/java/org/apache/polygene/api/identity/HasIdentity.java
+++ b/core/api/src/main/java/org/apache/polygene/api/identity/HasIdentity.java
@@ -49,7 +49,6 @@ public interface HasIdentity
         @State
         private Property<Identity> identity;
 
-
         @Override
         public Property<Identity> identity()
         {

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f819bfe3/core/api/src/main/java/org/apache/polygene/api/property/DefaultValues.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/property/DefaultValues.java b/core/api/src/main/java/org/apache/polygene/api/property/DefaultValues.java
index 4207358..848cbc0 100644
--- a/core/api/src/main/java/org/apache/polygene/api/property/DefaultValues.java
+++ b/core/api/src/main/java/org/apache/polygene/api/property/DefaultValues.java
@@ -36,7 +36,7 @@ import java.util.Set;
  */
 public final class DefaultValues
 {
-    private static final Map<Type, Object> DEFAULT_VALUES = new HashMap<Type, Object>();
+    private static final Map<Type, Object> DEFAULT_VALUES = new HashMap<>();
 
     static
     {

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f819bfe3/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Active.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Active.java
b/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Active.java
index 8428f36..8043a7b 100644
--- a/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Active.java
+++ b/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Active.java
@@ -45,7 +45,7 @@ public @interface Active
      * Active Annotation Qualifier.
      * See {@link Active}.
      */
-    public final class ActiveQualifier
+    final class ActiveQualifier
         implements AnnotationQualifier<Active>
     {
         @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f819bfe3/core/api/src/main/java/org/apache/polygene/api/service/qualifier/AnnotationQualifier.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/service/qualifier/AnnotationQualifier.java
b/core/api/src/main/java/org/apache/polygene/api/service/qualifier/AnnotationQualifier.java
index 8c35932..926fde8 100644
--- a/core/api/src/main/java/org/apache/polygene/api/service/qualifier/AnnotationQualifier.java
+++ b/core/api/src/main/java/org/apache/polygene/api/service/qualifier/AnnotationQualifier.java
@@ -29,5 +29,5 @@ import org.apache.polygene.api.service.ServiceReference;
  */
 public interface AnnotationQualifier<QUALIFIER extends Annotation>
 {
-    public <T> Predicate<ServiceReference<?>> qualifier( QUALIFIER qualifier
);
+    <T> Predicate<ServiceReference<?>> qualifier( QUALIFIER qualifier );
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f819bfe3/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Available.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Available.java
b/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Available.java
index 7af40d1..f8b955c 100644
--- a/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Available.java
+++ b/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Available.java
@@ -43,7 +43,7 @@ public @interface Available
      * Available Annotation Qualifier.
      * See {@link Available}.
      */
-    public final class AvailableQualifier
+    final class AvailableQualifier
         implements AnnotationQualifier<Available>
     {
         @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f819bfe3/core/api/src/main/java/org/apache/polygene/api/service/qualifier/HasMetaInfo.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/service/qualifier/HasMetaInfo.java
b/core/api/src/main/java/org/apache/polygene/api/service/qualifier/HasMetaInfo.java
index 73d551f..04fbad8 100644
--- a/core/api/src/main/java/org/apache/polygene/api/service/qualifier/HasMetaInfo.java
+++ b/core/api/src/main/java/org/apache/polygene/api/service/qualifier/HasMetaInfo.java
@@ -70,38 +70,33 @@ public @interface HasMetaInfo
      * HasMetaInfo Annotation Qualifier.
      * See {@link HasMetaInfo}.
      */
-    public static class HasMetaInfoQualifier
+    class HasMetaInfoQualifier
         implements AnnotationQualifier<HasMetaInfo>
     {
         @Override
         public <T> Predicate<ServiceReference<?>> qualifier( final HasMetaInfo
hasMetaInfo )
         {
-            return new Predicate<ServiceReference<?>>()
+            return service ->
             {
-                @Override
-                @SuppressWarnings( {"raw", "unchecked"} )
-                public boolean test( ServiceReference<?> service )
+                for( Class metaInfoType : hasMetaInfo.value() )
                 {
-                    for( Class metaInfoType : hasMetaInfo.value() )
+                    Object metaInfo = service.metaInfo( metaInfoType );
+                    if( hasMetaInfo.anded() )
                     {
-                        Object metaInfo = service.metaInfo( metaInfoType );
-                        if( hasMetaInfo.anded() )
+                        if( metaInfo == null )
                         {
-                            if( metaInfo == null )
-                            {
-                                return false;
-                            }
+                            return false;
                         }
-                        else
+                    }
+                    else
+                    {
+                        if( metaInfo != null )
                         {
-                            if( metaInfo != null )
-                            {
-                                return true;
-                            }
+                            return true;
                         }
                     }
-                    return false;
                 }
+                return false;
             };
         }
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f819bfe3/core/api/src/main/java/org/apache/polygene/api/service/qualifier/IdentifiedBy.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/service/qualifier/IdentifiedBy.java
b/core/api/src/main/java/org/apache/polygene/api/service/qualifier/IdentifiedBy.java
index 40c52bb..343f4cb 100644
--- a/core/api/src/main/java/org/apache/polygene/api/service/qualifier/IdentifiedBy.java
+++ b/core/api/src/main/java/org/apache/polygene/api/service/qualifier/IdentifiedBy.java
@@ -41,13 +41,13 @@ import org.apache.polygene.api.service.ServiceReference;
 @Qualifier( IdentifiedBy.IdentifiedByQualifier.class )
 public @interface IdentifiedBy
 {
-    public abstract String value();
+    String value();
 
     /**
      * IdentifiedBy Annotation Qualifier.
      * See {@link IdentifiedBy}.
      */
-    public final class IdentifiedByQualifier
+    final class IdentifiedByQualifier
         implements AnnotationQualifier<IdentifiedBy>
     {
         @Override

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f819bfe3/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Qualifier.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Qualifier.java
b/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Qualifier.java
index c0b183b..ca47474 100644
--- a/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Qualifier.java
+++ b/core/api/src/main/java/org/apache/polygene/api/service/qualifier/Qualifier.java
@@ -29,5 +29,5 @@ import java.lang.annotation.RetentionPolicy;
 @Retention( RetentionPolicy.RUNTIME )
 public @interface Qualifier
 {
-    public abstract Class<? extends AnnotationQualifier> value();
+    Class<? extends AnnotationQualifier> value();
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f819bfe3/core/api/src/main/java/org/apache/polygene/api/service/qualifier/ServiceQualifier.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/service/qualifier/ServiceQualifier.java
b/core/api/src/main/java/org/apache/polygene/api/service/qualifier/ServiceQualifier.java
index 8e6a948..bcc95d4 100644
--- a/core/api/src/main/java/org/apache/polygene/api/service/qualifier/ServiceQualifier.java
+++ b/core/api/src/main/java/org/apache/polygene/api/service/qualifier/ServiceQualifier.java
@@ -50,64 +50,34 @@ public abstract class ServiceQualifier
 {
     public static Predicate<ServiceReference<?>> withId( final String anId )
     {
-        return new Predicate<ServiceReference<?>>()
-        {
-            @Override
-            public boolean test( ServiceReference<?> service )
-            {
-                return service.identity().toString().equals( anId );
-            }
-        };
+        return service -> service.identity().toString().equals( anId );
     }
 
     public static Predicate<ServiceReference<?>> whereMetaInfoIs( final Object
metaInfo )
     {
-        return new Predicate<ServiceReference<?>>()
+        return service ->
         {
-            @Override
-            public boolean test( ServiceReference<?> service )
-            {
-                Object metaObject = service.metaInfo( metaInfo.getClass() );
-                return metaObject != null && metaInfo.equals( metaObject );
-            }
+            Object metaObject = service.metaInfo( metaInfo.getClass() );
+            return metaObject != null && metaInfo.equals( metaObject );
         };
     }
 
     public static Predicate<ServiceReference<?>> whereActive()
     {
-        return new Predicate<ServiceReference<?>>()
-        {
-            @Override
-            public boolean test( ServiceReference<?> service )
-            {
-                return service.isActive();
-            }
-        };
+        return ServiceReference::isActive;
     }
 
     public static Predicate<ServiceReference<?>> whereAvailable()
     {
-        return new Predicate<ServiceReference<?>>()
-        {
-            @Override
-            public boolean test( ServiceReference<?> service )
-            {
-                return service.isAvailable();
-            }
-        };
+        return ServiceReference::isAvailable;
     }
 
     public static Predicate<ServiceReference<?>> withTags( final String... tags
)
     {
-        return new Predicate<ServiceReference<?>>()
+        return service ->
         {
-            @Override
-            public boolean test( ServiceReference<?> service )
-            {
-                ServiceTags serviceTags = service.metaInfo( ServiceTags.class );
-
-                return serviceTags != null && serviceTags.hasTags( tags );
-            }
+            ServiceTags serviceTags = service.metaInfo( ServiceTags.class );
+            return serviceTags != null && serviceTags.hasTags( tags );
         };
     }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f819bfe3/core/api/src/main/java/org/apache/polygene/api/util/Classes.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/util/Classes.java b/core/api/src/main/java/org/apache/polygene/api/util/Classes.java
index 49ead26..8cbce1e 100644
--- a/core/api/src/main/java/org/apache/polygene/api/util/Classes.java
+++ b/core/api/src/main/java/org/apache/polygene/api/util/Classes.java
@@ -417,7 +417,7 @@ public final class Classes
             return subClass;
         } )
             .map( subClass -> resolveTypeVariable( name, declaringClass, mappings, subClass
) )
-            .filter( type -> type != null )
+            .filter( Objects::nonNull )
             .findAny().orElse( null );
     }
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f819bfe3/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstraintsCheck.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstraintsCheck.java
b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstraintsCheck.java
index 1f72dc3..ad24dbe 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstraintsCheck.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/ConstraintsCheck.java
@@ -27,6 +27,6 @@ import org.apache.polygene.api.constraint.ConstraintViolationException;
  */
 public interface ConstraintsCheck
 {
-    public void checkConstraints( Object value )
+    void checkConstraints( Object value )
         throws ConstraintViolationException;
 }


Mime
View raw message