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
|
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
|
* The name of the component being depended upon, or <code>null</code> if the dependency information is based on
|
||||||
* type.
|
* type.
|
||||||
|
@ -53,12 +72,7 @@ public class DependencyInfo
|
||||||
Objects.requireNonNull( klass );
|
Objects.requireNonNull( klass );
|
||||||
this.name = null;
|
this.name = null;
|
||||||
this.klass = klass;
|
this.klass = klass;
|
||||||
if ( klass.isPrimitive( ) ) {
|
DependencyInfo.checkClassValidity( klass );
|
||||||
throw new ComponentDefinitionException( "specified dependency is a primitive type" );
|
|
||||||
}
|
|
||||||
if ( klass.isArray( ) ) {
|
|
||||||
throw new ComponentDefinitionException( "specified dependency is an array type" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue