Skip to content

Commit f7c5310

Browse files
DiegoKrupitzaschauder
authored andcommitted
Explicit type replaced with diamond operator.
In modern java you do not need to add the explicit type if it can be inferred. To make the code more readable, we removed the explicit type and replaced it with the diamond operator (<>). Original pull request #2459
1 parent 1f29463 commit f7c5310

20 files changed

+42
-47
lines changed

spring-data-jpa/src/main/java/org/springframework/data/jpa/domain/JpaSort.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public JpaSort and(@Nullable Direction direction, Path<?, ?>... paths) {
161161

162162
Assert.notNull(paths, "Paths must not be null!");
163163

164-
List<Order> existing = new ArrayList<Order>();
164+
List<Order> existing = new ArrayList<>();
165165

166166
for (Order order : this) {
167167
existing.add(order);
@@ -181,7 +181,7 @@ public JpaSort andUnsafe(@Nullable Direction direction, String... properties) {
181181

182182
Assert.notEmpty(properties, "Properties must not be empty!");
183183

184-
List<Order> orders = new ArrayList<Order>();
184+
List<Order> orders = new ArrayList<>();
185185

186186
for (Order order : this) {
187187
orders.add(order);
@@ -216,7 +216,7 @@ public JpaSort andUnsafe(@Nullable Direction direction, String... properties) {
216216

217217
private static List<Order> combine(List<Order> orders, @Nullable Direction direction, List<Path<?, ?>> paths) {
218218

219-
List<Order> result = new ArrayList<Sort.Order>(orders);
219+
List<Order> result = new ArrayList<>(orders);
220220

221221
for (Path<?, ?> path : paths) {
222222
result.add(new Order(direction, path.toString()));
@@ -315,7 +315,7 @@ private Path(List<? extends Attribute<?, ?>> attributes) {
315315
* @return
316316
*/
317317
public <A extends Attribute<S, U>, U> Path<S, U> dot(A attribute) {
318-
return new Path<S, U>(add(attribute));
318+
return new Path<>(add(attribute));
319319
}
320320

321321
/**

spring-data-jpa/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,21 @@ class JpaPersistentPropertyImpl extends AnnotationBasedPersistentProperty<JpaPer
5757

5858
static {
5959

60-
Set<Class<? extends Annotation>> annotations = new HashSet<Class<? extends Annotation>>();
60+
Set<Class<? extends Annotation>> annotations = new HashSet<>();
6161
annotations.add(OneToMany.class);
6262
annotations.add(OneToOne.class);
6363
annotations.add(ManyToMany.class);
6464
annotations.add(ManyToOne.class);
6565

6666
ASSOCIATION_ANNOTATIONS = Collections.unmodifiableSet(annotations);
6767

68-
annotations = new HashSet<Class<? extends Annotation>>();
68+
annotations = new HashSet<>();
6969
annotations.add(Id.class);
7070
annotations.add(EmbeddedId.class);
7171

7272
ID_ANNOTATIONS = Collections.unmodifiableSet(annotations);
7373

74-
annotations = new HashSet<Class<? extends Annotation>>();
74+
annotations = new HashSet<>();
7575
annotations.add(Column.class);
7676
annotations.add(OrderColumn.class);
7777

@@ -150,7 +150,7 @@ public boolean isTransient() {
150150

151151
@Override
152152
protected Association<JpaPersistentProperty> createAssociation() {
153-
return new Association<JpaPersistentProperty>(this, null);
153+
return new Association<>(this, null);
154154
}
155155

156156
@Override

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/Jpa21Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private static EntityGraph<?> createDynamicEntityGraph(EntityManager em, JpaEnti
144144
*/
145145
static void configureFetchGraphFrom(JpaEntityGraph jpaEntityGraph, EntityGraph<?> entityGraph) {
146146

147-
List<String> attributePaths = new ArrayList<String>(jpaEntityGraph.getAttributePaths());
147+
List<String> attributePaths = new ArrayList<>(jpaEntityGraph.getAttributePaths());
148148

149149
// Sort to ensure that the intermediate entity subgraphs are created accordingly.
150150
Collections.sort(attributePaths);

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/DefaultJpaContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public DefaultJpaContext(Set<EntityManager> entityManagers) {
4747
Assert.notNull(entityManagers, "EntityManagers must not be null!");
4848
Assert.notEmpty(entityManagers, "EntityManagers must not be empty!");
4949

50-
this.entityManagers = new LinkedMultiValueMap<Class<?>, EntityManager>();
50+
this.entityManagers = new LinkedMultiValueMap<>();
5151

5252
for (EntityManager em : entityManagers) {
5353
for (ManagedType<?> managedType : em.getMetamodel().getManagedTypes()) {

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/JpaEntityInformationSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public abstract class JpaEntityInformationSupport<T, ID> extends AbstractEntityI
4242
*/
4343
public JpaEntityInformationSupport(Class<T> domainClass) {
4444
super(domainClass);
45-
this.metadata = new DefaultJpaEntityMetadata<T>(domainClass);
45+
this.metadata = new DefaultJpaEntityMetadata<>(domainClass);
4646
}
4747

4848
/**

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/Querydsl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ public <T> AbstractJPAQuery<T, JPAQuery<T>> createQuery() {
8080

8181
switch (provider) {
8282
case ECLIPSELINK:
83-
return new JPAQuery<T>(em, EclipseLinkTemplates.DEFAULT);
83+
return new JPAQuery<>(em, EclipseLinkTemplates.DEFAULT);
8484
case HIBERNATE:
85-
return new JPAQuery<T>(em, HQLTemplates.DEFAULT);
85+
return new JPAQuery<>(em, HQLTemplates.DEFAULT);
8686
case GENERIC_JPA:
8787
default:
88-
return new JPAQuery<T>(em);
88+
return new JPAQuery<>(em);
8989
}
9090
}
9191

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/QuerydslJpaRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public QuerydslJpaRepository(JpaEntityInformation<T, ID> entityInformation, Enti
9292
super(entityInformation, entityManager);
9393

9494
this.path = resolver.createPath(entityInformation.getJavaType());
95-
this.builder = new PathBuilder<T>(path.getType(), path.getMetadata());
95+
this.builder = new PathBuilder<>(path.getType(), path.getMetadata());
9696
this.querydsl = new Querydsl(entityManager, builder);
9797
this.entityManager = entityManager;
9898
}

spring-data-jpa/src/main/java/org/springframework/data/jpa/util/BeanDefinitionUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private BeanDefinitionUtils() {}
5353

5454
static {
5555

56-
List<Class<?>> types = new ArrayList<Class<?>>();
56+
List<Class<?>> types = new ArrayList<>();
5757
types.add(EntityManagerFactory.class);
5858
types.add(AbstractEntityManagerFactoryBean.class);
5959

@@ -96,7 +96,7 @@ public static Iterable<String> getEntityManagerFactoryBeanNames(ListableBeanFact
9696
public static Collection<EntityManagerFactoryBeanDefinition> getEntityManagerFactoryBeanDefinitions(
9797
ConfigurableListableBeanFactory beanFactory) {
9898

99-
Set<EntityManagerFactoryBeanDefinition> definitions = new HashSet<EntityManagerFactoryBeanDefinition>();
99+
Set<EntityManagerFactoryBeanDefinition> definitions = new HashSet<>();
100100

101101
for (Class<?> type : EMF_TYPES) {
102102

spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/Child.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class Child {
3131
Long id;
3232

3333
@ManyToMany(mappedBy = "children")
34-
Set<Parent> parents = new HashSet<Parent>();
34+
Set<Parent> parents = new HashSet<>();
3535

3636
/**
3737
* @param parent

spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/Parent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class Parent {
3434
static final long serialVersionUID = -89717120680485957L;
3535

3636
@ManyToMany(cascade = CascadeType.ALL)
37-
Set<Child> children = new HashSet<Child>();
37+
Set<Child> children = new HashSet<>();
3838

3939
public Parent add(Child child) {
4040

0 commit comments

Comments
 (0)