DATACMNS-406 - Polishing.
Refactored code in RepositoryMetadata implementations to avoid compiler warnings. Some JavaDoc polishing. Original pull request: #58.
This commit is contained in:
@@ -59,7 +59,8 @@ public abstract class AbstractRepositoryMetadata implements RepositoryMetadata {
|
||||
return Iterable.class.isAssignableFrom(rawType) ? returnTypeInfo.getComponentType().getType() : rawType;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.core.RepositoryMetadata#getRepositoryInterface()
|
||||
*/
|
||||
public Class<?> getRepositoryInterface() {
|
||||
|
||||
@@ -69,32 +69,24 @@ public class AnnotationRepositoryMetadata extends AbstractRepositoryMetadata {
|
||||
return this.domainType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param repositoryInterface must not be {@literal null}.
|
||||
* @return the resolved domain type, never {@literal null}.
|
||||
*/
|
||||
private Class<? extends Serializable> resolveIdType(Class<?> repositoryInterface) {
|
||||
|
||||
Assert.notNull(repositoryInterface, "Repository interface must not be null!");
|
||||
|
||||
RepositoryDefinition annotation = repositoryInterface.getAnnotation(RepositoryDefinition.class);
|
||||
Assert.isTrue(annotation != null && annotation.idClass() != null,
|
||||
String.format("Could not resolve id type of %s!", repositoryInterface));
|
||||
|
||||
if (annotation == null || annotation.idClass() == null) {
|
||||
throw new IllegalArgumentException(String.format("Could not resolve id type of %s!", repositoryInterface));
|
||||
}
|
||||
|
||||
return annotation.idClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param repositoryInterface must not be {@literal null}.
|
||||
* @return the resolved domain type, never {@literal null}.
|
||||
*/
|
||||
private Class<?> resolveDomainType(Class<?> repositoryInterface) {
|
||||
|
||||
Assert.notNull(repositoryInterface, "Repository interface must not be null!");
|
||||
|
||||
RepositoryDefinition annotation = repositoryInterface.getAnnotation(RepositoryDefinition.class);
|
||||
Assert.isTrue(annotation != null && annotation.domainClass() != null,
|
||||
String.format("Could not resolve domain type of %s!", repositoryInterface));
|
||||
|
||||
if (annotation == null || annotation.domainClass() == null) {
|
||||
throw new IllegalArgumentException(String.format("Could not resolve domain type of %s!", repositoryInterface));
|
||||
}
|
||||
|
||||
return annotation.domainClass();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DefaultRepositoryMetadata extends AbstractRepositoryMetadata {
|
||||
/**
|
||||
* Creates a new {@link DefaultRepositoryMetadata} for the given repository interface.
|
||||
*
|
||||
* @param repositoryInterface
|
||||
* @param repositoryInterface must not be {@literal null}.
|
||||
*/
|
||||
public DefaultRepositoryMetadata(Class<?> repositoryInterface) {
|
||||
|
||||
@@ -70,33 +70,26 @@ public class DefaultRepositoryMetadata extends AbstractRepositoryMetadata {
|
||||
return this.idType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param repositoryInterface must not be {@literal null}.
|
||||
* @return the resolved domain type, never {@literal null}.
|
||||
*/
|
||||
private Class<?> resolveDomainType(Class<?> repositoryInterface) {
|
||||
|
||||
Assert.notNull(repositoryInterface, "Repository interface must not be null!");
|
||||
|
||||
Class<?>[] arguments = resolveTypeArguments(repositoryInterface, Repository.class);
|
||||
Assert.isTrue(arguments != null && arguments[0] != null,
|
||||
String.format("Could not resolve domain type of %s!", repositoryInterface));
|
||||
|
||||
return arguments[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param repositoryInterface must not be {@literal null}.
|
||||
* @return the resolved id type, never {@literal null}.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private Class<? extends Serializable> resolveIdType(Class<?> repositoryInterface) {
|
||||
|
||||
Assert.notNull(repositoryInterface, "Repository interface must not be null!");
|
||||
|
||||
Class<?>[] arguments = resolveTypeArguments(repositoryInterface, Repository.class);
|
||||
Assert.isTrue(arguments != null && arguments[1] != null,
|
||||
String.format("Could not resolve id type of %s!", repositoryInterface));
|
||||
|
||||
if (arguments == null || arguments[1] == null) {
|
||||
throw new IllegalArgumentException(String.format("Could not resolve id type of %s!", repositoryInterface));
|
||||
}
|
||||
|
||||
return (Class<? extends Serializable>) arguments[1];
|
||||
}
|
||||
|
||||
private Class<?> resolveDomainType(Class<?> repositoryInterface) {
|
||||
|
||||
Class<?>[] arguments = resolveTypeArguments(repositoryInterface, Repository.class);
|
||||
|
||||
if (arguments == null || arguments[0] == null) {
|
||||
throw new IllegalArgumentException(String.format("Could not resolve domain type of %s!", repositoryInterface));
|
||||
}
|
||||
|
||||
return arguments[0];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user