You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by pa...@apache.org on 2017/02/26 22:47:28 UTC
[06/50] [abbrv] polygene-java git commit: POLYGENE-184 - Removed
NullArgumentException and replaced mostly with Objects.requireNonNull() and a
few "if( x.isEmpty() ) throw new IllegalArgumentException(); "
POLYGENE-184 - Removed NullArgumentException and replaced mostly with Objects.requireNonNull() and a few "if( x.isEmpty() ) throw new IllegalArgumentException();"
Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/c71f1b24
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/c71f1b24
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/c71f1b24
Branch: refs/heads/serialization-3.0
Commit: c71f1b24d010463b84a542f7c3fde50529dce6f0
Parents: 7e5f8e7
Author: niclas <ni...@spicter.com>
Authored: Tue Feb 21 10:11:27 2017 +0800
Committer: niclas <ni...@spicter.com>
Committed: Tue Feb 21 10:11:27 2017 +0800
----------------------------------------------------------------------
.../polygene/api/common/QualifiedName.java | 22 +++++---
.../apache/polygene/api/common/TypeName.java | 10 +++-
.../polygene/api/entity/EntityReference.java | 3 +-
.../polygene/api/query/QueryExpressions.java | 22 ++++----
.../org/apache/polygene/api/type/ValueType.java | 6 +-
.../api/util/NullArgumentException.java | 59 --------------------
.../polygene/api/common/QualifiedNameTest.java | 15 +++--
.../association/ManyAssociationInstance.java | 6 +-
.../association/NamedAssociationInstance.java | 4 +-
.../runtime/composite/CompositeMethodModel.java | 14 +++--
.../runtime/query/QueryBuilderFactoryImpl.java | 4 +-
.../runtime/structure/ModuleInstance.java | 21 ++++---
.../runtime/unitofwork/ModuleUnitOfWork.java | 10 ++--
.../instantiation/ValueInstantiationTests.java | 13 ++---
.../objects/ObjectBuilderFactoryTest.java | 5 +-
.../transients/TransientBuilderFactoryTest.java | 5 +-
.../test/cache/AbstractCachePoolTest.java | 7 +--
.../test/cache/MemoryCachePoolMixin.java | 16 +++---
.../test/mock/internal/MockResolverProxy.java | 12 ++--
.../cache/ehcache/EhCachePoolMixin.java | 8 ++-
.../cache/memcache/MemcachePoolMixin.java | 9 ++-
.../entitystore/cassandra/CassandraCluster.java | 1 +
.../internal/DatabaseSQLServiceCoreMixin.java | 6 +-
.../sql/internal/SQLEntityState.java | 10 ++--
.../apache/polygene/index/rdf/ContainsTest.java | 2 +-
.../restlet/crud/HasIdentitySpecification.java | 4 +-
.../sql/assembly/DataSourceAssembler.java | 6 +-
.../assembly/ExternalDataSourceAssembler.java | 6 +-
.../descriptor/ActivatorDetailDescriptor.java | 21 ++++---
.../descriptor/ApplicationDetailDescriptor.java | 9 ++-
.../descriptor/CompositeDetailDescriptor.java | 11 ++--
.../CompositeMethodDetailDescriptor.java | 13 ++---
.../descriptor/ConstructorDetailDescriptor.java | 17 +++---
.../ImportedServiceDetailDescriptor.java | 5 +-
.../InjectedFieldDetailDescriptor.java | 15 +++--
.../InjectedMethodDetailDescriptor.java | 16 +++---
.../InjectedParametersDetailDescriptor.java | 10 ++--
.../model/descriptor/LayerDetailDescriptor.java | 13 ++---
.../MethodConcernDetailDescriptor.java | 13 ++---
.../MethodConcernsDetailDescriptor.java | 9 ++-
.../MethodConstraintDetailDescriptor.java | 8 +--
.../MethodConstraintsDetailDescriptor.java | 10 ++--
.../MethodSideEffectDetailDescriptor.java | 15 ++---
.../MethodSideEffectsDetailDescriptor.java | 9 ++-
.../model/descriptor/MixinDetailDescriptor.java | 14 ++---
.../descriptor/ModuleDetailDescriptor.java | 21 ++++---
.../descriptor/ObjectDetailDescriptor.java | 13 ++---
.../descriptor/ServiceDetailDescriptor.java | 5 +-
48 files changed, 242 insertions(+), 311 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/api/src/main/java/org/apache/polygene/api/common/QualifiedName.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/common/QualifiedName.java b/core/api/src/main/java/org/apache/polygene/api/common/QualifiedName.java
index b0d0f18..79d4578 100644
--- a/core/api/src/main/java/org/apache/polygene/api/common/QualifiedName.java
+++ b/core/api/src/main/java/org/apache/polygene/api/common/QualifiedName.java
@@ -23,7 +23,7 @@ package org.apache.polygene.api.common;
import java.io.Serializable;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Member;
-import org.apache.polygene.api.util.NullArgumentException;
+import java.util.Objects;
/**
* QualifiedName is a representation of Property names to their full declaration.
@@ -68,11 +68,11 @@ public final class QualifiedName
*
* @return A QualifiedName representing this method.
*
- * @throws NullArgumentException If the {@code method} argument passed is null.
+ * @throws NullPointerException If the {@code method} argument passed is null.
*/
public static QualifiedName fromAccessor( AccessibleObject method )
{
- NullArgumentException.validateNotNull( "method", method );
+ Objects.requireNonNull( method, "method" );
return fromClass( ( (Member) method ).getDeclaringClass(), ( (Member) method ).getName() );
}
@@ -86,7 +86,8 @@ public final class QualifiedName
*
* @return A QualifiedName instance representing the {@code type} and {@code name} arguments.
*
- * @throws NullArgumentException if any of the two arguments are {@code null}, or if the name string is empty.
+ * @throws NullPointerException if any of the two arguments are {@code null}
+ * @throws IllegalArgumentException if the name string is empty.
*/
public static QualifiedName fromClass( Class type, String name )
{
@@ -102,7 +103,8 @@ public final class QualifiedName
*
* @return A QualifiedName instance representing the {@code type} and {@code name} arguments.
*
- * @throws NullArgumentException if any of the two arguments are {@code null} or either string is empty.
+ * @throws NullPointerException if any of the two arguments are {@code null}
+ * @throws IllegalArgumentException if the name string is empty.
*/
public static QualifiedName fromName( String type, String name )
{
@@ -121,11 +123,12 @@ public final class QualifiedName
*
* @return The QualifiedName instance represented by the {@code qualifiedName} argument.
*
+ * @throws NullPointerException If the {@code qualifiedName} argument is null
* @throws IllegalArgumentException If the {@code qualifiedName} argument has wrong format.
*/
public static QualifiedName fromFQN( String fullQualifiedName )
{
- NullArgumentException.validateNotEmpty( "qualifiedName", fullQualifiedName );
+ Objects.requireNonNull( fullQualifiedName, "qualifiedName" );
int idx = fullQualifiedName.lastIndexOf( ":" );
if( idx == -1 )
{
@@ -138,8 +141,11 @@ public final class QualifiedName
QualifiedName( TypeName typeName, String name )
{
- NullArgumentException.validateNotNull( "typeName", typeName );
- NullArgumentException.validateNotEmpty( "name", name );
+ Objects.requireNonNull( typeName, "typeName" );
+ Objects.requireNonNull( name, "name" );
+ if( name.isEmpty() ){
+ throw new IllegalArgumentException( "name" );
+ }
this.typeName = typeName;
this.name = name;
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/api/src/main/java/org/apache/polygene/api/common/TypeName.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/common/TypeName.java b/core/api/src/main/java/org/apache/polygene/api/common/TypeName.java
index 8ee64c8..a178929 100644
--- a/core/api/src/main/java/org/apache/polygene/api/common/TypeName.java
+++ b/core/api/src/main/java/org/apache/polygene/api/common/TypeName.java
@@ -21,8 +21,8 @@ package org.apache.polygene.api.common;
import java.io.Serializable;
import java.lang.reflect.Type;
+import java.util.Objects;
import org.apache.polygene.api.util.Classes;
-import org.apache.polygene.api.util.NullArgumentException;
/**
* Represents a Type name.
@@ -34,7 +34,7 @@ public final class TypeName
public static TypeName nameOf( Class type )
{
- NullArgumentException.validateNotNull( "type", type );
+ Objects.requireNonNull( type, "type" );
return new TypeName( type.getName() );
}
@@ -50,7 +50,11 @@ public final class TypeName
private TypeName( String name )
{
- NullArgumentException.validateNotEmpty( "name", name );
+ Objects.requireNonNull( name, "name" );
+ if( name.isEmpty() )
+ {
+ throw new IllegalArgumentException( "name was empty" );
+ }
this.name = name;
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java b/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
index fcfcb0e..c15532e 100644
--- a/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/EntityReference.java
@@ -24,7 +24,6 @@ import java.io.Serializable;
import java.util.Objects;
import org.apache.polygene.api.identity.Identity;
import org.apache.polygene.api.identity.StringIdentity;
-import org.apache.polygene.api.util.NullArgumentException;
/**
* An EntityReference is reference of a specific Entity instance.
@@ -69,7 +68,7 @@ public final class EntityReference
/**
* @param identity reference reference
- * @throws NullArgumentException if reference is null or empty
+ * @throws NullPointerException if reference is null
*/
private EntityReference( Identity identity )
{
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/api/src/main/java/org/apache/polygene/api/query/QueryExpressions.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/query/QueryExpressions.java b/core/api/src/main/java/org/apache/polygene/api/query/QueryExpressions.java
index 6b26751..945b176 100644
--- a/core/api/src/main/java/org/apache/polygene/api/query/QueryExpressions.java
+++ b/core/api/src/main/java/org/apache/polygene/api/query/QueryExpressions.java
@@ -30,6 +30,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.Objects;
import java.util.function.Predicate;
import org.apache.polygene.api.association.Association;
import org.apache.polygene.api.association.GenericAssociationInfo;
@@ -67,7 +68,6 @@ import org.apache.polygene.api.query.grammar.PropertyNotNullPredicate;
import org.apache.polygene.api.query.grammar.PropertyNullPredicate;
import org.apache.polygene.api.query.grammar.PropertyReference;
import org.apache.polygene.api.query.grammar.Variable;
-import org.apache.polygene.api.util.NullArgumentException;
import static org.apache.polygene.api.identity.HasIdentity.IDENTITY_METHOD;
@@ -90,7 +90,7 @@ public final class QueryExpressions
*/
public static <T> T templateFor( Class<T> clazz )
{
- NullArgumentException.validateNotNull( "Template class", clazz );
+ Objects.requireNonNull( clazz,"Template class" );
if( clazz.isInterface() )
{
@@ -157,8 +157,8 @@ public final class QueryExpressions
*/
public static <T> T templateFor( final Class<T> mixinType, Association<?> association )
{
- NullArgumentException.validateNotNull( "Mixin class", mixinType );
- NullArgumentException.validateNotNull( "Association", association );
+ Objects.requireNonNull( mixinType, "Mixin class" );
+ Objects.requireNonNull( association, "Association" );
return mixinType.cast( Proxy.newProxyInstance( mixinType.getClassLoader(),
array( mixinType ),
new TemplateHandler<T>( null,
@@ -169,13 +169,13 @@ public final class QueryExpressions
public static <T> T oneOf( final ManyAssociation<T> association )
{
- NullArgumentException.validateNotNull( "Association", association );
+ Objects.requireNonNull( association, "association" );
return association.get( 0 );
}
public static <T> T oneOf( final NamedAssociation<T> association )
{
- NullArgumentException.validateNotNull( "Association", association );
+ Objects.requireNonNull( association, "Association" );
Iterator<String> iterator = association.iterator();
return association.get( iterator.hasNext() ? iterator.next() : null );
}
@@ -189,7 +189,7 @@ public final class QueryExpressions
*/
public static Variable variable( String name )
{
- NullArgumentException.validateNotNull( "Variable name", name );
+ Objects.requireNonNull( name, "Variable name" );
return new Variable( name );
}
@@ -618,7 +618,7 @@ public final class QueryExpressions
public static <T> ContainsAllPredicate<T> containsAll( Property<? extends Collection<T>> collectionProperty,
Collection<T> values )
{
- NullArgumentException.validateNotNull( "Values", values );
+ Objects.requireNonNull( values, "Values" );
return new ContainsAllPredicate<>( property( collectionProperty ), values );
}
@@ -636,7 +636,7 @@ public final class QueryExpressions
Property<? extends Collection<T>> collectionProperty,
Collection<Variable> variables )
{
- NullArgumentException.validateNotNull( "Variables", variables );
+ Objects.requireNonNull( variables, "Variables" );
return new ContainsAllPredicate( property( collectionProperty ), variables );
}
@@ -652,7 +652,7 @@ public final class QueryExpressions
public static <T> ContainsPredicate<T> contains( Property<? extends Collection<T>> collectionProperty,
T value )
{
- NullArgumentException.validateNotNull( "Value", value );
+ Objects.requireNonNull( value, "Value" );
return new ContainsPredicate<>( property( collectionProperty ), value );
}
@@ -669,7 +669,7 @@ public final class QueryExpressions
public static <T> ContainsPredicate<T> contains( Property<? extends Collection<T>> collectionProperty,
Variable variable )
{
- NullArgumentException.validateNotNull( "Variable", variable );
+ Objects.requireNonNull( variable, "Variable" );
return new ContainsPredicate( property( collectionProperty ), variable );
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/api/src/main/java/org/apache/polygene/api/type/ValueType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/type/ValueType.java b/core/api/src/main/java/org/apache/polygene/api/type/ValueType.java
index fc39a0f..fee41cb 100644
--- a/core/api/src/main/java/org/apache/polygene/api/type/ValueType.java
+++ b/core/api/src/main/java/org/apache/polygene/api/type/ValueType.java
@@ -21,9 +21,9 @@ package org.apache.polygene.api.type;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import java.util.stream.Stream;
import org.apache.polygene.api.identity.Identity;
-import org.apache.polygene.api.util.NullArgumentException;
import static java.util.stream.Collectors.joining;
@@ -55,7 +55,7 @@ public class ValueType
*/
public static boolean isPrimitiveValue( Object object )
{
- NullArgumentException.validateNotNull( "object", object );
+ Objects.requireNonNull( object, "object" );
if( object instanceof String
|| object instanceof Character
|| object instanceof Boolean
@@ -109,7 +109,7 @@ public class ValueType
*/
public static boolean isPrimitiveValueType( Class<?> type )
{
- NullArgumentException.validateNotNull( "type", type );
+ Objects.requireNonNull( type, "type" );
if( String.class.isAssignableFrom( type ) )
{
return true;
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/api/src/main/java/org/apache/polygene/api/util/NullArgumentException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/util/NullArgumentException.java b/core/api/src/main/java/org/apache/polygene/api/util/NullArgumentException.java
deleted file mode 100644
index 927a438..0000000
--- a/core/api/src/main/java/org/apache/polygene/api/util/NullArgumentException.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.polygene.api.util;
-
-/**
- * Thrown if an argument to a method was null, and the method required
- * it to be non-null.
- */
-public class NullArgumentException
- extends IllegalArgumentException
-{
- private static final long serialVersionUID = 4815431779868729780L;
-
- private NullArgumentException( String message )
- {
- super( message );
- }
-
- public static void validateNotNull( String parameterName, Object value )
- {
- if( value != null )
- {
- return;
- }
- String message = parameterName + " was null.";
- throw new NullArgumentException( message );
- }
-
- public static void validateNotEmpty( String parameterName, String value )
- {
- if( value == null )
- {
- String message = parameterName + " was null.";
- throw new NullArgumentException( message );
- }
- if( value.length() == 0 )
- {
- String message = parameterName + " was empty.";
- throw new NullArgumentException( message );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/api/src/test/java/org/apache/polygene/api/common/QualifiedNameTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/apache/polygene/api/common/QualifiedNameTest.java b/core/api/src/test/java/org/apache/polygene/api/common/QualifiedNameTest.java
index e83ac81..d1f9086 100644
--- a/core/api/src/test/java/org/apache/polygene/api/common/QualifiedNameTest.java
+++ b/core/api/src/test/java/org/apache/polygene/api/common/QualifiedNameTest.java
@@ -20,7 +20,6 @@
package org.apache.polygene.api.common;
import org.junit.Test;
-import org.apache.polygene.api.util.NullArgumentException;
import static org.junit.Assert.assertEquals;
@@ -40,43 +39,43 @@ public class QualifiedNameTest
QualifiedName.fromFQN( "Test$Test:satisfiedBy" ).type() );
}
- @Test( expected = NullArgumentException.class )
+ @Test( expected = NullPointerException.class )
public void nonNullArguments1()
{
new QualifiedName( TypeName.nameOf( "Test" ), null );
}
- @Test( expected = NullArgumentException.class )
+ @Test( expected = NullPointerException.class )
public void nonNullArguments2()
{
new QualifiedName( null, "satisfiedBy" );
}
- @Test( expected = NullArgumentException.class )
+ @Test( expected = NullPointerException.class )
public void nonNullArguments3()
{
new QualifiedName( null, null );
}
- @Test( expected = NullArgumentException.class )
+ @Test( expected = NullPointerException.class )
public void nonNullArguments4()
{
QualifiedName.fromFQN( null );
}
- @Test( expected = NullArgumentException.class )
+ @Test( expected = NullPointerException.class )
public void nonNullArguments5()
{
QualifiedName.fromAccessor( null );
}
- @Test( expected = NullArgumentException.class )
+ @Test( expected = NullPointerException.class )
public void nonNullArguments6()
{
QualifiedName.fromClass( null, "satisfiedBy" );
}
- @Test( expected = NullArgumentException.class )
+ @Test( expected = NullPointerException.class )
public void nonNullArguments7()
{
QualifiedName.fromClass( null, null );
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/runtime/src/main/java/org/apache/polygene/runtime/association/ManyAssociationInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/association/ManyAssociationInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/association/ManyAssociationInstance.java
index b035745..a30acf7 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/association/ManyAssociationInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/association/ManyAssociationInstance.java
@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.stream.Stream;
@@ -32,7 +33,6 @@ import org.apache.polygene.api.association.ManyAssociation;
import org.apache.polygene.api.association.ManyAssociationWrapper;
import org.apache.polygene.api.entity.EntityReference;
import org.apache.polygene.api.identity.HasIdentity;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.spi.entity.ManyAssociationState;
/**
@@ -68,7 +68,7 @@ public class ManyAssociationInstance<T>
@Override
public boolean add( int i, T entity )
{
- NullArgumentException.validateNotNull( "entity", entity );
+ Objects.requireNonNull( entity, "entity" );
checkImmutable();
checkType( entity );
associationInfo.checkConstraints( entity );
@@ -84,7 +84,7 @@ public class ManyAssociationInstance<T>
@Override
public boolean remove( T entity )
{
- NullArgumentException.validateNotNull( "entity", entity );
+ Objects.requireNonNull( entity, "entity" );
checkImmutable();
checkType( entity );
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/runtime/src/main/java/org/apache/polygene/runtime/association/NamedAssociationInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/association/NamedAssociationInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/association/NamedAssociationInstance.java
index 05aa878..c351e0f 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/association/NamedAssociationInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/association/NamedAssociationInstance.java
@@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -34,7 +35,6 @@ import org.apache.polygene.api.association.NamedAssociation;
import org.apache.polygene.api.association.NamedAssociationWrapper;
import org.apache.polygene.api.entity.EntityReference;
import org.apache.polygene.api.identity.HasIdentity;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.spi.entity.NamedAssociationState;
public class NamedAssociationInstance<T>
@@ -74,7 +74,7 @@ public class NamedAssociationInstance<T>
@Override
public boolean put( String name, T entity )
{
- NullArgumentException.validateNotNull( "entity", entity );
+ Objects.requireNonNull( entity, "entity" );
checkImmutable();
checkType( entity );
associationInfo.checkConstraints( entity );
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeMethodModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeMethodModel.java b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeMethodModel.java
index 267c065..4d21359 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeMethodModel.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/CompositeMethodModel.java
@@ -29,13 +29,13 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
+import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.polygene.api.common.ConstructionException;
import org.apache.polygene.api.composite.MethodDescriptor;
import org.apache.polygene.api.structure.ModuleDescriptor;
import org.apache.polygene.api.util.HierarchicalVisitor;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.api.util.VisitableHierarchy;
import org.apache.polygene.runtime.injection.Dependencies;
import org.apache.polygene.runtime.injection.DependencyModel;
@@ -100,7 +100,11 @@ public final class CompositeMethodModel
@SuppressWarnings( "unchecked" )
public Stream<DependencyModel> dependencies()
{
- return Stream.of( this.concerns, sideEffects ).filter( Objects::nonNull ).flatMap( Dependencies::dependencies );
+ Stream<? extends Dependencies> fragments = Stream.of( this.concerns, sideEffects );
+ Stream<? extends Dependencies> nonNullFragments = fragments.filter( Objects::nonNull );
+ Function<? super Dependencies, Stream<? extends DependencyModel>> dependencies = Dependencies::dependencies;
+ Stream<DependencyModel> modelStream = nonNullFragments.flatMap( dependencies );
+ return modelStream;
}
// Context
@@ -302,14 +306,14 @@ public final class CompositeMethodModel
@SuppressWarnings( "unchecked" )
public <T extends Annotation> T[] getAnnotationsByType( Class<T> annotationClass )
{
- NullArgumentException.validateNotNull( "annotationClass", annotationClass );
+ Objects.requireNonNull( annotationClass, "annotationClass" );
return (T[]) Array.newInstance( annotationClass, 0 );
}
// @Override (Since JDK 8)
public <T extends Annotation> T getDeclaredAnnotation( Class<T> annotationClass )
{
- NullArgumentException.validateNotNull( "annotationClass", annotationClass );
+ Objects.requireNonNull( annotationClass, "annotationClass" );
return null;
}
@@ -317,7 +321,7 @@ public final class CompositeMethodModel
@SuppressWarnings( "unchecked" )
public <T extends Annotation> T[] getDeclaredAnnotationsByType( Class<T> annotationClass )
{
- NullArgumentException.validateNotNull( "annotationClass", annotationClass );
+ Objects.requireNonNull( annotationClass, "annotationClass" );
return (T[]) Array.newInstance( annotationClass, 0 );
}
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/runtime/src/main/java/org/apache/polygene/runtime/query/QueryBuilderFactoryImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/query/QueryBuilderFactoryImpl.java b/core/runtime/src/main/java/org/apache/polygene/runtime/query/QueryBuilderFactoryImpl.java
index 2cf716b..caaf5c9 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/query/QueryBuilderFactoryImpl.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/query/QueryBuilderFactoryImpl.java
@@ -19,13 +19,13 @@
*/
package org.apache.polygene.runtime.query;
+import java.util.Objects;
import org.apache.polygene.api.query.NotQueryableException;
import org.apache.polygene.api.query.QueryBuilder;
import org.apache.polygene.api.query.QueryBuilderFactory;
import org.apache.polygene.api.service.NoSuchServiceException;
import org.apache.polygene.api.service.ServiceFinder;
import org.apache.polygene.api.service.ServiceReference;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.spi.query.EntityFinder;
/**
@@ -43,7 +43,7 @@ public final class QueryBuilderFactoryImpl
*/
public QueryBuilderFactoryImpl( ServiceFinder finder )
{
- NullArgumentException.validateNotNull( "ServiceFinder", finder );
+ Objects.requireNonNull( finder, "ServiceFinder" );
this.finder = finder;
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
index 3735130..246f0ab 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/structure/ModuleInstance.java
@@ -61,7 +61,6 @@ import org.apache.polygene.api.structure.TypeLookup;
import org.apache.polygene.api.type.HasTypes;
import org.apache.polygene.api.unitofwork.UnitOfWorkException;
import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.api.value.NoSuchValueException;
import org.apache.polygene.api.value.ValueBuilder;
import org.apache.polygene.api.value.ValueBuilderFactory;
@@ -169,7 +168,7 @@ public class ModuleInstance
public <T> T newObject( Class<T> mixinType, Object... uses )
throws NoSuchObjectException
{
- NullArgumentException.validateNotNull( "mixinType", mixinType );
+ Objects.requireNonNull( mixinType, "mixinType" );
ObjectDescriptor model = typeLookup.lookupObjectModel( mixinType );
if( model == null )
@@ -186,7 +185,7 @@ public class ModuleInstance
public void injectTo( Object instance, Object... uses )
throws ConstructionException
{
- NullArgumentException.validateNotNull( "instance", instance );
+ Objects.requireNonNull( instance, "instance" );
ObjectDescriptor model = typeLookup.lookupObjectModel( instance.getClass() );
if( model == null )
@@ -204,7 +203,7 @@ public class ModuleInstance
public <T> TransientBuilder<T> newTransientBuilder( Class<T> mixinType )
throws NoSuchTransientException
{
- NullArgumentException.validateNotNull( "mixinType", mixinType );
+ Objects.requireNonNull( mixinType, "mixinType" );
TransientDescriptor model = typeLookup.lookupTransientModel( mixinType );
if( model == null )
@@ -246,7 +245,7 @@ public class ModuleInstance
public <T> ValueBuilder<T> newValueBuilder( Class<T> mixinType )
throws NoSuchValueException
{
- NullArgumentException.validateNotNull( "mixinType", mixinType );
+ Objects.requireNonNull( mixinType, "mixinType" );
ValueDescriptor compositeModelModule = typeLookup.lookupValueModel( mixinType );
if( compositeModelModule == null )
@@ -266,10 +265,10 @@ public class ModuleInstance
Function<AssociationDescriptor, Stream<Map.Entry<String, EntityReference>>> namedAssociationFunction
)
{
- NullArgumentException.validateNotNull( "propertyFunction", propertyFunction );
- NullArgumentException.validateNotNull( "associationFunction", associationFunction );
- NullArgumentException.validateNotNull( "manyAssociationFunction", manyAssociationFunction );
- NullArgumentException.validateNotNull( "namedAssociationFunction", namedAssociationFunction );
+ Objects.requireNonNull( propertyFunction, "propertyFunction" );
+ Objects.requireNonNull( associationFunction, "associationFunction" );
+ Objects.requireNonNull( manyAssociationFunction, "manyAssociationFunction" );
+ Objects.requireNonNull( namedAssociationFunction, "namedAssociationFunction" );
ValueDescriptor compositeModelModule = typeLookup.lookupValueModel( mixinType );
@@ -323,7 +322,7 @@ public class ModuleInstance
@SuppressWarnings( "unchecked" )
public <T> ValueBuilder<T> newValueBuilderWithPrototype( T prototype )
{
- NullArgumentException.validateNotNull( "prototype", prototype );
+ Objects.requireNonNull( prototype, "prototype" );
ValueInstance valueInstance = ValueInstance.valueInstanceOf( (ValueComposite) prototype );
Class<Composite> valueType = (Class<Composite>) valueInstance.types().findFirst().orElse( null );
@@ -342,7 +341,7 @@ public class ModuleInstance
public <T> T newValueFromSerializedState( Class<T> mixinType, String serializedState )
throws NoSuchValueException, ConstructionException
{
- NullArgumentException.validateNotNull( "mixinType", mixinType );
+ Objects.requireNonNull( mixinType, "mixinType" );
ValueDescriptor model = typeLookup.lookupValueModel( mixinType );
if( model == null )
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java b/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java
index bd18383..542cc0a 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/unitofwork/ModuleUnitOfWork.java
@@ -24,6 +24,7 @@ import java.time.Instant;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Predicate;
@@ -64,7 +65,6 @@ import org.apache.polygene.api.unitofwork.UnitOfWorkCallback;
import org.apache.polygene.api.unitofwork.UnitOfWorkCompletionException;
import org.apache.polygene.api.unitofwork.UnitOfWorkFactory;
import org.apache.polygene.api.usecase.Usecase;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.api.value.ValueBuilder;
import org.apache.polygene.api.value.ValueComposite;
import org.apache.polygene.runtime.association.AssociationInstance;
@@ -233,10 +233,10 @@ public class ModuleUnitOfWork
)
throws NoSuchEntityTypeException
{
- NullArgumentException.validateNotNull( "propertyFunction", propertyFunction );
- NullArgumentException.validateNotNull( "associationFunction", associationFunction );
- NullArgumentException.validateNotNull( "manyAssociationFunction", manyAssociationFunction );
- NullArgumentException.validateNotNull( "namedAssociationFunction", namedAssociationFunction );
+ Objects.requireNonNull( propertyFunction, "propertyFunction" );
+ Objects.requireNonNull( associationFunction, "associationFunction" );
+ Objects.requireNonNull( manyAssociationFunction, "manyAssociationFunction" );
+ Objects.requireNonNull( namedAssociationFunction, "namedAssociationFunction" );
EntityDescriptor model = module.typeLookup().lookupEntityModel( type );
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/runtime/src/test/java/org/apache/polygene/runtime/instantiation/ValueInstantiationTests.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/instantiation/ValueInstantiationTests.java b/core/runtime/src/test/java/org/apache/polygene/runtime/instantiation/ValueInstantiationTests.java
index d22f0d3..666d3d1 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/instantiation/ValueInstantiationTests.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/instantiation/ValueInstantiationTests.java
@@ -22,7 +22,6 @@ package org.apache.polygene.runtime.instantiation;
import org.junit.Assert;
import org.junit.Test;
import org.apache.polygene.api.mixin.Mixins;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.api.value.ValueBuilder;
import org.apache.polygene.api.value.ValueComposite;
import org.apache.polygene.bootstrap.AssemblyException;
@@ -49,9 +48,9 @@ public class ValueInstantiationTests
try
{
valueBuilderFactory.newValueBuilder( null );
- fail( "NullArgumentException was expected." );
+ fail( "NullPointerException was expected." );
}
- catch( NullArgumentException e )
+ catch( NullPointerException e )
{
// expected
}
@@ -60,9 +59,9 @@ public class ValueInstantiationTests
try
{
valueBuilderFactory.newValue( null );
- fail( "NullArgumentException was expected." );
+ fail( "NullPointerException was expected." );
}
- catch( NullArgumentException e )
+ catch( NullPointerException e )
{
// expected
}
@@ -72,9 +71,9 @@ public class ValueInstantiationTests
{
valueBuilderFactory.newValueFromSerializedState( null, "abc:123" );
ValueBuilder<My> builder = valueBuilderFactory.newValueBuilder( null );
- fail( "NullArgumentException was expected." );
+ fail( "NullPointerException was expected." );
}
- catch( NullArgumentException e )
+ catch( NullPointerException e )
{
// expected
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectBuilderFactoryTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectBuilderFactoryTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectBuilderFactoryTest.java
index 924bcdc..f978aa0 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectBuilderFactoryTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/objects/ObjectBuilderFactoryTest.java
@@ -27,7 +27,6 @@ import org.apache.polygene.api.injection.scope.Structure;
import org.apache.polygene.api.injection.scope.Uses;
import org.apache.polygene.api.object.NoSuchObjectException;
import org.apache.polygene.api.structure.Module;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.bootstrap.AssemblyException;
import org.apache.polygene.bootstrap.ModuleAssembly;
import org.apache.polygene.bootstrap.SingletonAssembler;
@@ -65,7 +64,7 @@ public class ObjectBuilderFactoryTest
*
* @throws Exception expected
*/
- @Test( expected = NullArgumentException.class )
+ @Test( expected = NullPointerException.class )
public void newBuilderForNullType()
throws Exception
{
@@ -84,7 +83,7 @@ public class ObjectBuilderFactoryTest
*
* @throws Exception expected
*/
- @Test( expected = NullArgumentException.class )
+ @Test( expected = NullPointerException.class )
public void newObjectInstanceForNullType()
throws Exception
{
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientBuilderFactoryTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientBuilderFactoryTest.java b/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientBuilderFactoryTest.java
index fd3fb63..9383841 100644
--- a/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientBuilderFactoryTest.java
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/transients/TransientBuilderFactoryTest.java
@@ -34,7 +34,6 @@ import org.apache.polygene.api.injection.scope.Structure;
import org.apache.polygene.api.injection.scope.This;
import org.apache.polygene.api.property.Property;
import org.apache.polygene.api.structure.Module;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.bootstrap.AssemblyException;
import org.apache.polygene.bootstrap.ModuleAssembly;
import org.apache.polygene.bootstrap.SingletonAssembler;
@@ -72,7 +71,7 @@ public class TransientBuilderFactoryTest
*
* @throws Exception expected
*/
- @Test( expected = NullArgumentException.class )
+ @Test( expected = NullPointerException.class )
public void newBuilderForNullType()
throws Exception
{
@@ -91,7 +90,7 @@ public class TransientBuilderFactoryTest
*
* @throws Exception expected
*/
- @Test( expected = NullArgumentException.class )
+ @Test( expected = NullPointerException.class )
public void newInstanceForNullType()
throws Exception
{
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/testsupport/src/main/java/org/apache/polygene/test/cache/AbstractCachePoolTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/cache/AbstractCachePoolTest.java b/core/testsupport/src/main/java/org/apache/polygene/test/cache/AbstractCachePoolTest.java
index 6e236fd..3d5120f 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/cache/AbstractCachePoolTest.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/cache/AbstractCachePoolTest.java
@@ -25,7 +25,6 @@ import org.apache.polygene.test.AbstractPolygeneTest;
import org.junit.Test;
import org.apache.polygene.api.constraint.ConstraintViolation;
import org.apache.polygene.api.constraint.ConstraintViolationException;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.spi.cache.Cache;
import org.apache.polygene.spi.cache.CachePool;
@@ -57,16 +56,16 @@ public abstract class AbstractCachePoolTest
try
{
cache = cachePool.fetchCache( "", String.class );
- fail( "Expected " + NullArgumentException.class.getSimpleName() );
+ fail( "Expected " + IllegalArgumentException.class.getSimpleName() );
}
- catch( NullArgumentException e )
+ catch( IllegalArgumentException e )
{
// expected
}
try
{
cache = cachePool.fetchCache( null, String.class );
- fail( "Expected " + NullArgumentException.class.getSimpleName() );
+ fail( "Expected " + NullPointerException.class.getSimpleName() );
}
catch( ConstraintViolationException e )
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/testsupport/src/main/java/org/apache/polygene/test/cache/MemoryCachePoolMixin.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/cache/MemoryCachePoolMixin.java b/core/testsupport/src/main/java/org/apache/polygene/test/cache/MemoryCachePoolMixin.java
index 28f46bf..b682bf9 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/cache/MemoryCachePoolMixin.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/cache/MemoryCachePoolMixin.java
@@ -19,8 +19,8 @@
*/
package org.apache.polygene.test.cache;
+import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.spi.cache.Cache;
import static org.apache.polygene.api.util.Collectors.single;
@@ -36,20 +36,20 @@ public abstract class MemoryCachePoolMixin
@Override
public <T> Cache<T> fetchCache( String cacheId, Class<T> valueType )
{
- NullArgumentException.validateNotEmpty( "cacheId", cacheId );
- MemoryCacheImpl<?> cache = caches.get( cacheId );
- if( cache == null )
+ Objects.requireNonNull( cacheId, "cacheId" );
+ if( cacheId.isEmpty() )
{
- cache = createNewCache( cacheId, valueType );
- caches.put( cacheId, cache );
+ throw new IllegalArgumentException( "cacheId was empty string" );
}
+ @SuppressWarnings( "unchecked" )
+ MemoryCacheImpl<T> cache = (MemoryCacheImpl<T>) caches.computeIfAbsent( cacheId, k -> createNewCache( cacheId, valueType ) );
cache.incRefCount();
- return (Cache<T>) cache;
+ return cache;
}
private <T> MemoryCacheImpl<T> createNewCache( String cacheId, Class<T> valueType )
{
- return new MemoryCacheImpl<>( cacheId, new ConcurrentHashMap<String, Object>(), valueType );
+ return new MemoryCacheImpl<>( cacheId, new ConcurrentHashMap<>(), valueType );
}
@Override
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/core/testsupport/src/main/java/org/apache/polygene/test/mock/internal/MockResolverProxy.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/polygene/test/mock/internal/MockResolverProxy.java b/core/testsupport/src/main/java/org/apache/polygene/test/mock/internal/MockResolverProxy.java
index f43c683..d4d75b9 100644
--- a/core/testsupport/src/main/java/org/apache/polygene/test/mock/internal/MockResolverProxy.java
+++ b/core/testsupport/src/main/java/org/apache/polygene/test/mock/internal/MockResolverProxy.java
@@ -21,7 +21,7 @@ package org.apache.polygene.test.mock.internal;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
-import org.apache.polygene.api.util.NullArgumentException;
+import java.util.Objects;
/**
* Proxy to another mock resolver that can be set/changed over time. This allows
@@ -45,13 +45,13 @@ public class MockResolverProxy
* @param registeredMock registered mock; cannot be null
* @param mockResolver mock resolver delegate; cannot be null
*
- * @throws NullArgumentException - If registred mock is null
+ * @throws NullPointerException - If registred mock is null
* - If mock resolver is null
*/
MockResolverProxy( final Object registeredMock, final MockResolver mockResolver )
{
- NullArgumentException.validateNotNull( "Registered mock", registeredMock );
- NullArgumentException.validateNotNull( "Mock resolver delegate", mockResolver );
+ Objects.requireNonNull( registeredMock, "Registered mock" );
+ Objects.requireNonNull( mockResolver, "Mock resolver delegate" );
this.registeredMock = registeredMock;
this.mockResolver = mockResolver;
}
@@ -63,11 +63,11 @@ public class MockResolverProxy
*
* @return itself
*
- * @throws NullArgumentException - If mock resolver is null
+ * @throws NullPointerException - If mock resolver is null
*/
MockResolverProxy setMock( final MockResolver mockResolver )
{
- NullArgumentException.validateNotNull( "Mock resolver delegate", mockResolver );
+ Objects.requireNonNull( mockResolver, "Mock resolver delegate" );
this.mockResolver = mockResolver;
return this;
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/extensions/cache-ehcache/src/main/java/org/apache/polygene/cache/ehcache/EhCachePoolMixin.java
----------------------------------------------------------------------
diff --git a/extensions/cache-ehcache/src/main/java/org/apache/polygene/cache/ehcache/EhCachePoolMixin.java b/extensions/cache-ehcache/src/main/java/org/apache/polygene/cache/ehcache/EhCachePoolMixin.java
index 7a82741..ab9c593 100644
--- a/extensions/cache-ehcache/src/main/java/org/apache/polygene/cache/ehcache/EhCachePoolMixin.java
+++ b/extensions/cache-ehcache/src/main/java/org/apache/polygene/cache/ehcache/EhCachePoolMixin.java
@@ -19,13 +19,13 @@
*/
package org.apache.polygene.cache.ehcache;
+import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import org.apache.polygene.api.configuration.Configuration;
import org.apache.polygene.api.identity.HasIdentity;
import org.apache.polygene.api.injection.scope.This;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.spi.cache.Cache;
import org.ehcache.CacheManager;
import org.ehcache.config.CacheConfiguration;
@@ -77,7 +77,11 @@ public abstract class EhCachePoolMixin
// Note: Small bug in Ehcache; If the cache name is an empty String it will actually work until
// you try to remove the Cache instance from the CacheManager, at which point it is silently
// ignored but not removed so there is a follow up problem of too much in the CacheManager.
- NullArgumentException.validateNotEmpty( "cacheId", cacheId );
+ Objects.requireNonNull( cacheId, "cacheId" );
+ if( cacheId.isEmpty() )
+ {
+ throw new IllegalArgumentException( "cacheId was empty string" );
+ }
EhCacheImpl<?> cache = caches.computeIfAbsent( cacheId, key -> createNewCache( cacheId, valueType ) );
cache.incRefCount();
return (Cache<T>) cache;
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/extensions/cache-memcache/src/main/java/org/apache/polygene/cache/memcache/MemcachePoolMixin.java
----------------------------------------------------------------------
diff --git a/extensions/cache-memcache/src/main/java/org/apache/polygene/cache/memcache/MemcachePoolMixin.java b/extensions/cache-memcache/src/main/java/org/apache/polygene/cache/memcache/MemcachePoolMixin.java
index e0c9f2d..dabaea0 100644
--- a/extensions/cache-memcache/src/main/java/org/apache/polygene/cache/memcache/MemcachePoolMixin.java
+++ b/extensions/cache-memcache/src/main/java/org/apache/polygene/cache/memcache/MemcachePoolMixin.java
@@ -21,6 +21,7 @@ package org.apache.polygene.cache.memcache;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
import net.spy.memcached.AddrUtil;
import net.spy.memcached.ConnectionFactoryBuilder;
import net.spy.memcached.ConnectionFactoryBuilder.Protocol;
@@ -32,8 +33,6 @@ import org.apache.polygene.api.configuration.Configuration;
import org.apache.polygene.api.injection.scope.This;
import org.apache.polygene.spi.cache.Cache;
-import static org.apache.polygene.api.util.NullArgumentException.validateNotEmpty;
-
/**
* Memcache CachePool Mixin.
*/
@@ -101,7 +100,11 @@ public class MemcachePoolMixin
@SuppressWarnings( "unchecked" )
public <T> Cache<T> fetchCache( String cacheId, Class<T> valueType )
{
- validateNotEmpty( "cacheId", cacheId );
+ Objects.requireNonNull( cacheId, "cacheId" );
+ if( cacheId.isEmpty() )
+ {
+ throw new IllegalArgumentException( "cacheId was empty string" );
+ }
synchronized( caches )
{
MemcacheImpl<?> cache = caches.get( cacheId );
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
index 48d0137..6b5d4d4 100644
--- a/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
+++ b/extensions/entitystore-cassandra/src/main/java/org/apache/polygene/entitystore/cassandra/CassandraCluster.java
@@ -25,6 +25,7 @@ import com.datastax.driver.core.KeyspaceMetadata;
import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.exceptions.AlreadyExistsException;
+import java.util.Objects;
import org.apache.polygene.api.common.Optional;
import org.apache.polygene.api.configuration.Configuration;
import org.apache.polygene.api.injection.scope.Service;
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/internal/DatabaseSQLServiceCoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/internal/DatabaseSQLServiceCoreMixin.java b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/internal/DatabaseSQLServiceCoreMixin.java
index 301f222..3c37457 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/internal/DatabaseSQLServiceCoreMixin.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/internal/DatabaseSQLServiceCoreMixin.java
@@ -22,6 +22,7 @@ package org.apache.polygene.entitystore.sql.internal;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.Objects;
import javax.sql.DataSource;
import org.apache.polygene.api.configuration.Configuration;
import org.apache.polygene.api.injection.scope.Service;
@@ -31,7 +32,6 @@ import org.apache.polygene.api.injection.scope.Uses;
import org.apache.polygene.api.service.ServiceDescriptor;
import org.apache.polygene.api.structure.Application;
import org.apache.polygene.api.structure.Application.Mode;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.library.sql.common.SQLConfiguration;
import org.apache.polygene.library.sql.common.SQLUtil;
import org.apache.polygene.spi.entitystore.EntityStoreException;
@@ -141,13 +141,13 @@ public abstract class DatabaseSQLServiceCoreMixin
protected String getConfiguredSchemaName( String defaultSchemaName )
{
if ( configuration == null ) {
- NullArgumentException.validateNotNull( "default schema name", defaultSchemaName );
+ Objects.requireNonNull( defaultSchemaName, "default schema name" );
LOGGER.debug( "No configuration, will use default schema name: '{}'", defaultSchemaName );
return defaultSchemaName;
}
String result = configuration.get().schemaName().get();
if ( result == null ) {
- NullArgumentException.validateNotNull( "default schema name", defaultSchemaName );
+ Objects.requireNonNull( defaultSchemaName, "default schema name" );
result = defaultSchemaName;
LOGGER.debug( "No database schema name in configuration, will use default: '{}'", defaultSchemaName );
} else {
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/internal/SQLEntityState.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/internal/SQLEntityState.java b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/internal/SQLEntityState.java
index c6569a4..2db6f7c 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/internal/SQLEntityState.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/polygene/entitystore/sql/internal/SQLEntityState.java
@@ -20,10 +20,10 @@
package org.apache.polygene.entitystore.sql.internal;
import java.time.Instant;
+import java.util.Objects;
import org.apache.polygene.api.common.QualifiedName;
import org.apache.polygene.api.entity.EntityDescriptor;
import org.apache.polygene.api.entity.EntityReference;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.spi.entity.EntityState;
import org.apache.polygene.spi.entity.EntityStatus;
import org.apache.polygene.spi.entity.ManyAssociationState;
@@ -53,7 +53,7 @@ public interface SQLEntityState
public DefaultSQLEntityState( DefaultEntityState state )
{
- NullArgumentException.validateNotNull( "Entity state", state );
+ Objects.requireNonNull( state, "Entity state" );
this.state = state;
this.entityPK = null;
this.entityOptimisticLock = null;
@@ -61,9 +61,9 @@ public interface SQLEntityState
public DefaultSQLEntityState( DefaultEntityState state, Long entityPK, Long entityOptimisticLock )
{
- NullArgumentException.validateNotNull( "Entity state", state );
- NullArgumentException.validateNotNull( "Entity PK", entityPK );
- NullArgumentException.validateNotNull( "Entity OptimisticLock", entityOptimisticLock );
+ Objects.requireNonNull( state, "Entity state" );
+ Objects.requireNonNull( entityPK, "Entity PK" );
+ Objects.requireNonNull( entityOptimisticLock, "Entity OptimisticLock" );
this.state = state;
this.entityPK = entityPK;
this.entityOptimisticLock = entityOptimisticLock;
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/ContainsTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/ContainsTest.java b/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/ContainsTest.java
index 7e76e3d..f96bc90 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/ContainsTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/polygene/index/rdf/ContainsTest.java
@@ -98,7 +98,7 @@ public class ContainsTest extends AbstractPolygeneTest
Assert.assertTrue( "The entity must not have been found", result == null );
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = NullPointerException.class )
public void simplecontainsNullTest() throws Exception
{
this.performContainsStringTest(
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/HasIdentitySpecification.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/HasIdentitySpecification.java b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/HasIdentitySpecification.java
index 18b61ef..ce359ca 100644
--- a/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/HasIdentitySpecification.java
+++ b/libraries/restlet/src/main/java/org/apache/polygene/library/restlet/crud/HasIdentitySpecification.java
@@ -20,10 +20,10 @@
package org.apache.polygene.library.restlet.crud;
+import java.util.Objects;
import java.util.function.Predicate;
import org.apache.polygene.api.identity.HasIdentity;
import org.apache.polygene.api.identity.Identity;
-import org.apache.polygene.api.util.NullArgumentException;
public class HasIdentitySpecification
implements Predicate<HasIdentity>
@@ -32,7 +32,7 @@ public class HasIdentitySpecification
public HasIdentitySpecification(Identity identity )
{
- NullArgumentException.validateNotNull( "reference", identity );
+ Objects.requireNonNull( identity, "reference" );
this.id = identity;
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java
index 5155d9f..e6a3d78 100644
--- a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java
+++ b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/DataSourceAssembler.java
@@ -19,10 +19,10 @@
*/
package org.apache.polygene.library.sql.assembly;
+import java.util.Objects;
import javax.sql.DataSource;
import org.apache.polygene.api.identity.StringIdentity;
import org.apache.polygene.api.service.importer.ServiceInstanceImporter;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.bootstrap.Assemblers;
import org.apache.polygene.bootstrap.AssemblyException;
import org.apache.polygene.bootstrap.ModuleAssembly;
@@ -48,7 +48,7 @@ public class DataSourceAssembler
public DataSourceAssembler withDataSourceServiceIdentity( String dataSourceServiceId )
{
- NullArgumentException.validateNotNull( "DataSourceService reference", dataSourceServiceId );
+ Objects.requireNonNull( dataSourceServiceId, "DataSourceService reference" );
this.dataSourceServiceId = dataSourceServiceId;
return this;
}
@@ -61,7 +61,7 @@ public class DataSourceAssembler
public DataSourceAssembler withCircuitBreaker( CircuitBreaker circuitBreaker )
{
- NullArgumentException.validateNotNull( "CircuitBreaker", circuitBreaker );
+ Objects.requireNonNull( circuitBreaker, "CircuitBreaker" );
this.circuitBreaker = circuitBreaker;
return this;
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java
index c20bb6d..4af36cf 100644
--- a/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java
+++ b/libraries/sql/src/main/java/org/apache/polygene/library/sql/assembly/ExternalDataSourceAssembler.java
@@ -19,9 +19,9 @@
*/
package org.apache.polygene.library.sql.assembly;
+import java.util.Objects;
import javax.sql.DataSource;
import org.apache.polygene.api.identity.StringIdentity;
-import org.apache.polygene.api.util.NullArgumentException;
import org.apache.polygene.bootstrap.Assemblers;
import org.apache.polygene.bootstrap.AssemblyException;
import org.apache.polygene.bootstrap.ModuleAssembly;
@@ -44,7 +44,7 @@ public class ExternalDataSourceAssembler
public ExternalDataSourceAssembler( DataSource externalDataSource )
{
- NullArgumentException.validateNotNull( "DataSource", externalDataSource );
+ Objects.requireNonNull( externalDataSource, "DataSource" );
this.externalDataSource = externalDataSource;
}
@@ -56,7 +56,7 @@ public class ExternalDataSourceAssembler
public ExternalDataSourceAssembler withCircuitBreaker( CircuitBreaker circuitBreaker )
{
- NullArgumentException.validateNotNull( "CircuitBreaker", circuitBreaker );
+ Objects.requireNonNull( circuitBreaker, "CircuitBreaker" );
this.circuitBreaker = circuitBreaker;
return this;
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ActivatorDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ActivatorDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ActivatorDetailDescriptor.java
index e3be45c..0b331e2 100644
--- a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ActivatorDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ActivatorDetailDescriptor.java
@@ -21,12 +21,11 @@ package org.apache.polygene.tools.model.descriptor;
import java.util.LinkedList;
import java.util.List;
+import java.util.Objects;
import org.apache.polygene.api.activation.ActivatorDescriptor;
import org.apache.polygene.api.util.Visitable;
import org.apache.polygene.api.util.Visitor;
-import static org.apache.polygene.api.util.NullArgumentException.validateNotNull;
-
/**
* Activator Detail Descriptor.
*/
@@ -45,7 +44,7 @@ public class ActivatorDetailDescriptor
public ActivatorDetailDescriptor( ActivatorDescriptor descriptor )
{
- validateNotNull( "Activator Descriptor", descriptor );
+ Objects.requireNonNull( descriptor, "Activator Descriptor" );
this.descriptor = descriptor;
constructors = new LinkedList<>();
injectedMethods = new LinkedList<>();
@@ -112,38 +111,38 @@ public class ActivatorDetailDescriptor
final void setService( ServiceDetailDescriptor descriptor )
{
- validateNotNull( "ServiceDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ServiceDetailDescriptor" );
service = descriptor;
}
final void setImportedService( ImportedServiceDetailDescriptor descriptor )
{
- validateNotNull( "ImportedServiceDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ImportedServiceDetailDescriptor" );
importedService = descriptor;
}
final void setModule( ModuleDetailDescriptor descriptor )
{
- validateNotNull( "ModuleDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ModuleDetailDescriptor" );
module = descriptor;
}
final void setLayer( LayerDetailDescriptor descriptor )
{
- validateNotNull( "LayerDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "LayerDetailDescriptor" );
layer = descriptor;
}
final void setApplication( ApplicationDetailDescriptor descriptor )
{
- validateNotNull( "ApplicationDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ApplicationDetailDescriptor" );
application = descriptor;
}
final void addConstructor( ConstructorDetailDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "ConstructorDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ConstructorDetailDescriptor" );
descriptor.setActivator( this );
constructors.add( descriptor );
}
@@ -151,14 +150,14 @@ public class ActivatorDetailDescriptor
final void addInjectedMethod( InjectedMethodDetailDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "InjectedMethodDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "InjectedMethodDetailDescriptor" );
descriptor.setActivator( this );
injectedMethods.add( descriptor );
}
final void addInjectedField( InjectedFieldDetailDescriptor descriptor )
{
- validateNotNull( "InjectedFieldDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "InjectedFieldDetailDescriptor" );
descriptor.setActivator( this );
injectedFields.add( descriptor );
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ApplicationDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ApplicationDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ApplicationDetailDescriptor.java
index f574dec..fd3abc3 100644
--- a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ApplicationDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ApplicationDetailDescriptor.java
@@ -21,12 +21,11 @@ package org.apache.polygene.tools.model.descriptor;
import java.util.LinkedList;
import java.util.List;
+import java.util.Objects;
import org.apache.polygene.api.structure.ApplicationDescriptor;
import org.apache.polygene.api.util.HierarchicalVisitor;
import org.apache.polygene.api.util.VisitableHierarchy;
-import static org.apache.polygene.api.util.NullArgumentException.validateNotNull;
-
/**
* Application Detail Descriptor.
* <p>
@@ -42,7 +41,7 @@ public final class ApplicationDetailDescriptor
ApplicationDetailDescriptor( ApplicationDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "ApplicationDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ApplicationDescriptor" );
this.descriptor = descriptor;
}
@@ -70,14 +69,14 @@ public final class ApplicationDetailDescriptor
final void addActivator( ActivatorDetailDescriptor descriptor )
{
- validateNotNull( "ActivatorDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ActivatorDetailDescriptor" );
descriptor.setApplication( this );
activators.add( descriptor );
}
final void addLayer( LayerDetailDescriptor descriptor )
{
- validateNotNull( "LayerDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "LayerDetailDescriptor" );
descriptor.setApplication( this );
layers.add( descriptor );
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/CompositeDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/CompositeDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/CompositeDetailDescriptor.java
index d8c95d0..3b5e0e3 100644
--- a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/CompositeDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/CompositeDetailDescriptor.java
@@ -22,11 +22,10 @@ package org.apache.polygene.tools.model.descriptor;
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.List;
+import java.util.Objects;
import org.apache.polygene.api.composite.CompositeDescriptor;
import org.apache.polygene.api.composite.MethodDescriptor;
-import static org.apache.polygene.api.util.NullArgumentException.validateNotNull;
-
/**
* Composite Detail Descriptor.
*
@@ -41,7 +40,7 @@ public abstract class CompositeDetailDescriptor<T extends CompositeDescriptor>
CompositeDetailDescriptor( T aDescriptor )
{
- validateNotNull( "aDescriptor", aDescriptor );
+ Objects.requireNonNull( aDescriptor, "aDescriptor" );
descriptor = aDescriptor;
methods = new LinkedList<>();
@@ -115,14 +114,14 @@ public abstract class CompositeDetailDescriptor<T extends CompositeDescriptor>
final void setModule( ModuleDetailDescriptor aDescriptor )
throws IllegalArgumentException
{
- validateNotNull( "aDescriptor", aDescriptor );
+ Objects.requireNonNull( aDescriptor, "aDescriptor" );
module = aDescriptor;
}
final void addMethod( CompositeMethodDetailDescriptor aDescriptor )
throws IllegalArgumentException
{
- validateNotNull( "aDescriptor", aDescriptor );
+ Objects.requireNonNull( aDescriptor, "aDescriptor" );
aDescriptor.setComposite( this );
methods.add( aDescriptor );
@@ -131,7 +130,7 @@ public abstract class CompositeDetailDescriptor<T extends CompositeDescriptor>
final void addMixin( MixinDetailDescriptor aDescriptor )
throws IllegalArgumentException
{
- validateNotNull( "aDescriptor", aDescriptor );
+ Objects.requireNonNull( aDescriptor, "aDescriptor" );
aDescriptor.setComposite( this );
mixins.add( aDescriptor );
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/CompositeMethodDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/CompositeMethodDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/CompositeMethodDetailDescriptor.java
index db1341a..7a2bda4 100644
--- a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/CompositeMethodDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/CompositeMethodDetailDescriptor.java
@@ -19,10 +19,9 @@
*/
package org.apache.polygene.tools.model.descriptor;
+import java.util.Objects;
import org.apache.polygene.api.composite.MethodDescriptor;
-import static org.apache.polygene.api.util.NullArgumentException.validateNotNull;
-
public final class CompositeMethodDetailDescriptor
{
private final MethodDescriptor descriptor;
@@ -35,7 +34,7 @@ public final class CompositeMethodDetailDescriptor
CompositeMethodDetailDescriptor( MethodDescriptor aDescriptor )
throws IllegalArgumentException
{
- validateNotNull( "aDescriptor", aDescriptor );
+ Objects.requireNonNull( aDescriptor, "aDescriptor" );
descriptor = aDescriptor;
composite = null;
@@ -99,14 +98,14 @@ public final class CompositeMethodDetailDescriptor
final void setComposite( CompositeDetailDescriptor aDescriptor )
throws IllegalArgumentException
{
- validateNotNull( "aDescriptor", aDescriptor );
+ Objects.requireNonNull( aDescriptor, "aDescriptor" );
composite = aDescriptor;
}
final void setConstraints( MethodConstraintsDetailDescriptor aDescriptor )
throws IllegalArgumentException
{
- validateNotNull( "aDescriptor", aDescriptor );
+ Objects.requireNonNull( aDescriptor, "aDescriptor" );
aDescriptor.setMethod( this );
constraints = aDescriptor;
@@ -114,7 +113,7 @@ public final class CompositeMethodDetailDescriptor
public void setConcerns( MethodConcernsDetailDescriptor aDescriptor )
{
- validateNotNull( "aDescriptor", aDescriptor );
+ Objects.requireNonNull( aDescriptor, "aDescriptor" );
aDescriptor.setMethod( this );
concerns = aDescriptor;
@@ -122,7 +121,7 @@ public final class CompositeMethodDetailDescriptor
final void setSideEffects( MethodSideEffectsDetailDescriptor aDescriptor )
{
- validateNotNull( "aDescriptor", aDescriptor );
+ Objects.requireNonNull( aDescriptor, "aDescriptor" );
aDescriptor.setMethod( this );
sideEffects = aDescriptor;
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ConstructorDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ConstructorDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ConstructorDetailDescriptor.java
index 72b01f4..152fdaa 100644
--- a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ConstructorDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ConstructorDetailDescriptor.java
@@ -19,10 +19,9 @@
*/
package org.apache.polygene.tools.model.descriptor;
+import java.util.Objects;
import org.apache.polygene.api.composite.ConstructorDescriptor;
-import static org.apache.polygene.api.util.NullArgumentException.validateNotNull;
-
/**
* Constructor Detail Descriptor.
*/
@@ -39,7 +38,7 @@ public final class ConstructorDetailDescriptor
ConstructorDetailDescriptor( ConstructorDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "ConstructorDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ConstructorDescriptor" );
this.descriptor = descriptor;
this.parameters = null;
}
@@ -102,38 +101,38 @@ public final class ConstructorDetailDescriptor
final void setActivator( ActivatorDetailDescriptor descriptor )
{
- validateNotNull( "ActivatorDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ActivatorDetailDescriptor" );
activator = descriptor;
}
final void setObject( ObjectDetailDescriptor descriptor )
{
- validateNotNull( "ObjectDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ObjectDetailDescriptor" );
object = descriptor;
}
final void setMixin( MixinDetailDescriptor descriptor )
{
- validateNotNull( "MixinDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "MixinDetailDescriptor" );
mixin = descriptor;
}
final void setMethodConcern( MethodConcernDetailDescriptor descriptor )
{
- validateNotNull( "MethodConcernDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "MethodConcernDetailDescriptor" );
methodConcern = descriptor;
}
final void setInjectedParameter( InjectedParametersDetailDescriptor descriptor )
{
- validateNotNull( "InjectedParametersDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "InjectedParametersDetailDescriptor" );
descriptor.setConstructor( this );
parameters = descriptor;
}
final void setMethodSideEffect( MethodSideEffectDetailDescriptor descriptor )
{
- validateNotNull( "MethodSideEffectDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "MethodSideEffectDetailDescriptor" );
methodSideEffect = descriptor;
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ImportedServiceDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ImportedServiceDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ImportedServiceDetailDescriptor.java
index a8a1989..7f64a79 100644
--- a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ImportedServiceDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/ImportedServiceDetailDescriptor.java
@@ -21,11 +21,10 @@ package org.apache.polygene.tools.model.descriptor;
import java.util.LinkedList;
import java.util.List;
+import java.util.Objects;
import org.apache.polygene.api.util.HierarchicalVisitor;
import org.apache.polygene.api.util.VisitableHierarchy;
-import static org.apache.polygene.api.util.NullArgumentException.validateNotNull;
-
/**
* Imported Service Detail Descriptor.
* <p>
@@ -51,7 +50,7 @@ public class ImportedServiceDetailDescriptor
final void addActivator( ActivatorDetailDescriptor descriptor )
{
- validateNotNull( "ActivatorDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ActivatorDetailDescriptor" );
descriptor.setImportedService( this );
activators.add( descriptor );
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/InjectedFieldDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/InjectedFieldDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/InjectedFieldDetailDescriptor.java
index cf15390..b1a635c 100644
--- a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/InjectedFieldDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/InjectedFieldDetailDescriptor.java
@@ -19,10 +19,9 @@
*/
package org.apache.polygene.tools.model.descriptor;
+import java.util.Objects;
import org.apache.polygene.api.composite.InjectedFieldDescriptor;
-import static org.apache.polygene.api.util.NullArgumentException.validateNotNull;
-
public final class InjectedFieldDetailDescriptor
{
private final InjectedFieldDescriptor descriptor;
@@ -35,7 +34,7 @@ public final class InjectedFieldDetailDescriptor
InjectedFieldDetailDescriptor( InjectedFieldDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "InjectedFieldDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "InjectedFieldDescriptor" );
this.descriptor = descriptor;
}
@@ -89,35 +88,35 @@ public final class InjectedFieldDetailDescriptor
final void setActivator( ActivatorDetailDescriptor descriptor )
{
- validateNotNull( "ActivatorDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ActivatorDetailDescriptor" );
activator = descriptor;
}
final void setObject( ObjectDetailDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "ObjectDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ObjectDetailDescriptor" );
object = descriptor;
}
final void setMixin( MixinDetailDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "MixinDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "MixinDetailDescriptor" );
mixin = descriptor;
}
final void setMethodConcern( MethodConcernDetailDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "MethodConcernDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "MethodConcernDetailDescriptor" );
methodConcern = descriptor;
}
final void setMethodSideEffect( MethodSideEffectDetailDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "MethodSideEffectDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "MethodSideEffectDetailDescriptor" );
methodSideEffect = descriptor;
}
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/c71f1b24/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/InjectedMethodDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/InjectedMethodDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/InjectedMethodDetailDescriptor.java
index 6ba127f..a7e6fe7 100644
--- a/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/InjectedMethodDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/polygene/tools/model/descriptor/InjectedMethodDetailDescriptor.java
@@ -19,9 +19,9 @@
*/
package org.apache.polygene.tools.model.descriptor;
+import java.util.Objects;
import org.apache.polygene.api.composite.InjectedMethodDescriptor;
-import static org.apache.polygene.api.util.NullArgumentException.validateNotNull;
public final class InjectedMethodDetailDescriptor
{
@@ -36,7 +36,7 @@ public final class InjectedMethodDetailDescriptor
InjectedMethodDetailDescriptor( InjectedMethodDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "InjectedMethodDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "InjectedMethodDescriptor" );
this.descriptor = descriptor;
this.parameters = null;
}
@@ -99,28 +99,28 @@ public final class InjectedMethodDetailDescriptor
final void setActivator( ActivatorDetailDescriptor descriptor )
{
- validateNotNull( "ActivatorDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ActivatorDetailDescriptor" );
activator = descriptor;
}
final void setObject( ObjectDetailDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "ObjectDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "ObjectDetailDescriptor" );
object = descriptor;
}
final void setMixin( MixinDetailDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "MixinDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "MixinDetailDescriptor" );
mixin = descriptor;
}
final void setInjectedParameter( InjectedParametersDetailDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "InjectedParametersDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "InjectedParametersDetailDescriptor" );
descriptor.setMethod( this );
parameters = descriptor;
@@ -129,14 +129,14 @@ public final class InjectedMethodDetailDescriptor
final void setMethodSideEffect( MethodSideEffectDetailDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "MethodSideEffectDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "MethodSideEffectDetailDescriptor" );
methodSideEffect = descriptor;
}
final void setMethodConcern( MethodConcernDetailDescriptor descriptor )
throws IllegalArgumentException
{
- validateNotNull( "MethodConcernDetailDescriptor", descriptor );
+ Objects.requireNonNull( descriptor, "MethodConcernDetailDescriptor" );
methodConcern = descriptor;
}