Browse Source

DATAMONGO-1289 - Polishing.

Some additional JavaDoc and comment removal.

Original pull request: #333.
pull/337/merge
Oliver Gierke 10 years ago
parent
commit
3feed2bc5a
  1. 21
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/MappingMongoEntityInformation.java
  2. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/MongoRepositoryFactory.java
  3. 3
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/NoExplicitIdTests.java

21
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/MappingMongoEntityInformation.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2015 by the original author(s).
* Copyright 2011-2015 by the original author(s).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -46,6 +46,13 @@ public class MappingMongoEntityInformation<T, ID extends Serializable> extends P @@ -46,6 +46,13 @@ public class MappingMongoEntityInformation<T, ID extends Serializable> extends P
this(entity, null, null);
}
/**
* Creates a new {@link MappingMongoEntityInformation} for the given {@link MongoPersistentEntity} and fallback
* identifier type.
*
* @param entity must not be {@literal null}.
* @param fallbackIdType can be {@literal null}.
*/
public MappingMongoEntityInformation(MongoPersistentEntity<T> entity, Class<ID> fallbackIdType) {
this(entity, (String) null, fallbackIdType);
}
@ -61,7 +68,17 @@ public class MappingMongoEntityInformation<T, ID extends Serializable> extends P @@ -61,7 +68,17 @@ public class MappingMongoEntityInformation<T, ID extends Serializable> extends P
this(entity, customCollectionName, null);
}
public MappingMongoEntityInformation(MongoPersistentEntity<T> entity, String customCollectionName, Class<ID> idType) {
/**
* Creates a new {@link MappingMongoEntityInformation} for the given {@link MongoPersistentEntity}, collection name
* and identifier type.
*
* @param entity must not be {@literal null}.
* @param customCollectionName can be {@literal null}.
* @param idType can be {@literal null}.
*/
@SuppressWarnings("unchecked")
private MappingMongoEntityInformation(MongoPersistentEntity<T> entity, String customCollectionName,
Class<ID> idType) {
super(entity);

6
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/MongoRepositoryFactory.java

@ -108,8 +108,6 @@ public class MongoRepositoryFactory extends RepositoryFactorySupport { @@ -108,8 +108,6 @@ public class MongoRepositoryFactory extends RepositoryFactorySupport {
* (non-Javadoc)
* @see org.springframework.data.repository.core.support.RepositoryFactorySupport#getEntityInformation(java.lang.Class)
*/
// TODO: would be worth discussing if we could alter RepositoryFactorySupport#getEntityInformation to be called with
// RepositoryMetadata instead of the acual domain type class.
public <T, ID extends Serializable> MongoEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
return getEntityInformation(domainClass, null);
}
@ -121,8 +119,8 @@ public class MongoRepositoryFactory extends RepositoryFactorySupport { @@ -121,8 +119,8 @@ public class MongoRepositoryFactory extends RepositoryFactorySupport {
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(domainClass);
if (entity == null) {
throw new MappingException(String.format("Could not lookup mapping metadata for domain class %s!",
domainClass.getName()));
throw new MappingException(
String.format("Could not lookup mapping metadata for domain class %s!", domainClass.getName()));
}
return new MappingMongoEntityInformation<T, ID>((MongoPersistentEntity<T>) entity,

3
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/NoExplicitIdTests.java

@ -37,6 +37,8 @@ import com.mongodb.Mongo; @@ -37,6 +37,8 @@ import com.mongodb.Mongo;
import com.mongodb.MongoClient;
/**
* Integration tests for DATAMONGO-1289.
*
* @author Christoph Strobl
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ -102,6 +104,7 @@ public class NoExplicitIdTests { @@ -102,6 +104,7 @@ public class NoExplicitIdTests {
* @see DATAMONGO-1289
*/
@Test
@SuppressWarnings("unchecked")
public void saveAndRetrieveTypeWithoutIdPorpertyViaRepositoryFindOne() {
TypeWithoutIdProperty noid = new TypeWithoutIdProperty();

Loading…
Cancel
Save