Dependency info - separate class validation method
This commit is contained in:
parent
a95d71e770
commit
a1ddf5f63a
1 changed files with 20 additions and 6 deletions
|
@ -13,6 +13,25 @@ import java.util.Objects;
|
|||
public class DependencyInfo
|
||||
{
|
||||
|
||||
/**
|
||||
* Checks that a class can be used as a dependency
|
||||
*
|
||||
* @param klass
|
||||
* the class to check
|
||||
* @throws ComponentDefinitionException
|
||||
* if the specified "class" is in fact a primitive or array type
|
||||
*/
|
||||
public static void checkClassValidity( final Class< ? > klass )
|
||||
throws ComponentDefinitionException
|
||||
{
|
||||
if ( klass.isPrimitive( ) ) {
|
||||
throw new ComponentDefinitionException( "specified dependency is a primitive type" );
|
||||
}
|
||||
if ( klass.isArray( ) ) {
|
||||
throw new ComponentDefinitionException( "specified dependency is an array type" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the component being depended upon, or <code>null</code> if the dependency information is based on
|
||||
* type.
|
||||
|
@ -53,12 +72,7 @@ public class DependencyInfo
|
|||
Objects.requireNonNull( klass );
|
||||
this.name = null;
|
||||
this.klass = klass;
|
||||
if ( klass.isPrimitive( ) ) {
|
||||
throw new ComponentDefinitionException( "specified dependency is a primitive type" );
|
||||
}
|
||||
if ( klass.isArray( ) ) {
|
||||
throw new ComponentDefinitionException( "specified dependency is an array type" );
|
||||
}
|
||||
DependencyInfo.checkClassValidity( klass );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue