Skip to content

Commit f6a6565

Browse files
christophstroblodrotbohm
authored andcommitted
DATACMNS-1101 - Remove getPersistentProperties/Associations from PersistentEntity.
Remove lately introduced getPersistentProperties / getAssociations and rather extend Iterable<? extends PersistentProperty<P>>
1 parent 88ac1fc commit f6a6565

File tree

3 files changed

+8
-30
lines changed

3 files changed

+8
-30
lines changed

src/main/java/org/springframework/data/mapping/PersistentEntity.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @author Mark Paluch
3232
* @author Christoph Strobl
3333
*/
34-
public interface PersistentEntity<T, P extends PersistentProperty<P>> {
34+
public interface PersistentEntity<T, P extends PersistentProperty<P>> extends Iterable<P> {
3535

3636
/**
3737
* The entity name including any package prefix.
@@ -224,14 +224,6 @@ default P getPersistentProperty(Class<? extends Annotation> annotationType) {
224224

225225
void doWithProperties(SimplePropertyHandler handler);
226226

227-
/**
228-
* Get {@link Iterable}
229-
*
230-
* @return
231-
* @since 2.0
232-
*/
233-
Iterable<P> getPersistentProperties();
234-
235227
/**
236228
* Applies the given {@link AssociationHandler} to all {@link Association} contained in this {@link PersistentEntity}.
237229
*
@@ -241,8 +233,6 @@ default P getPersistentProperty(Class<? extends Annotation> annotationType) {
241233

242234
void doWithAssociations(SimpleAssociationHandler handler);
243235

244-
Iterable<Association<P>> getAssociations();
245-
246236
/**
247237
* Looks up the annotation of the given type on the {@link PersistentEntity}.
248238
*

src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.Comparator;
2626
import java.util.HashMap;
2727
import java.util.HashSet;
28+
import java.util.Iterator;
2829
import java.util.List;
2930
import java.util.Map;
3031
import java.util.Optional;
@@ -353,15 +354,6 @@ public void doWithProperties(SimplePropertyHandler handler) {
353354
}
354355
}
355356

356-
/*
357-
* (non-Javadoc)
358-
* @see org.springframework.data.mapping.PersistentEntity#getPersistentProperties()
359-
*/
360-
@Override
361-
public List<P> getPersistentProperties() {
362-
return Collections.unmodifiableList(persistentPropertiesCache);
363-
}
364-
365357
/*
366358
* (non-Javadoc)
367359
* @see org.springframework.data.mapping.PersistentEntity#doWithAssociations(org.springframework.data.mapping.AssociationHandler)
@@ -388,15 +380,6 @@ public void doWithAssociations(SimpleAssociationHandler handler) {
388380
}
389381
}
390382

391-
/*
392-
* (non-Javadoc)
393-
* @see org.springframework.data.mapping.PersistentEntity#getAssociations()
394-
*/
395-
@Override
396-
public Set<Association<P>> getAssociations() {
397-
return Collections.unmodifiableSet(associations);
398-
}
399-
400383
/*
401384
* (non-Javadoc)
402385
* @see org.springframework.data.mapping.PersistentEntity#findAnnotation(java.lang.Class)
@@ -471,6 +454,11 @@ public IdentifierAccessor getIdentifierAccessor(Object bean) {
471454
return hasIdProperty() ? new IdPropertyIdentifierAccessor(this, bean) : new AbsentIdentifierAccessor(bean);
472455
}
473456

457+
@Override
458+
public Iterator<P> iterator() {
459+
return Collections.unmodifiableList(properties).iterator();
460+
}
461+
474462
/**
475463
* Calculates the {@link Alias} to be used for the given type.
476464
*

src/test/java/org/springframework/data/mapping/context/AbstractMappingContextUnitTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public void returnsEntityForComponentType() {
155155

156156
assertThat(entity.getPersistentProperty("persons"))
157157
.satisfies(it -> assertThat(mappingContext.getPersistentEntity(it))
158-
.satisfies(inner -> assertThat(inner.getType()).isEqualTo(Person.class)));
158+
.satisfies(inner -> assertThat(((PersistentEntity)inner).getType()).isEqualTo(Person.class)));
159159
}
160160

161161
@Test // DATACMNS-380

0 commit comments

Comments
 (0)