Skip to content

Explicit type replaced with diamond operator. #2459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public JpaSort and(@Nullable Direction direction, Path<?, ?>... paths) {

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

List<Order> existing = new ArrayList<Order>();
List<Order> existing = new ArrayList<>();

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

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

List<Order> orders = new ArrayList<Order>();
List<Order> orders = new ArrayList<>();

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

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

List<Order> result = new ArrayList<Sort.Order>(orders);
List<Order> result = new ArrayList<>(orders);

for (Path<?, ?> path : paths) {
result.add(new Order(direction, path.toString()));
Expand Down Expand Up @@ -315,7 +315,7 @@ private Path(List<? extends Attribute<?, ?>> attributes) {
* @return
*/
public <A extends Attribute<S, U>, U> Path<S, U> dot(A attribute) {
return new Path<S, U>(add(attribute));
return new Path<>(add(attribute));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,21 @@ class JpaPersistentPropertyImpl extends AnnotationBasedPersistentProperty<JpaPer

static {

Set<Class<? extends Annotation>> annotations = new HashSet<Class<? extends Annotation>>();
Set<Class<? extends Annotation>> annotations = new HashSet<>();
annotations.add(OneToMany.class);
annotations.add(OneToOne.class);
annotations.add(ManyToMany.class);
annotations.add(ManyToOne.class);

ASSOCIATION_ANNOTATIONS = Collections.unmodifiableSet(annotations);

annotations = new HashSet<Class<? extends Annotation>>();
annotations = new HashSet<>();
annotations.add(Id.class);
annotations.add(EmbeddedId.class);

ID_ANNOTATIONS = Collections.unmodifiableSet(annotations);

annotations = new HashSet<Class<? extends Annotation>>();
annotations = new HashSet<>();
annotations.add(Column.class);
annotations.add(OrderColumn.class);

Expand Down Expand Up @@ -187,7 +187,7 @@ public boolean isTransient() {
*/
@Override
protected Association<JpaPersistentProperty> createAssociation() {
return new Association<JpaPersistentProperty>(this, null);
return new Association<>(this, null);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private static EntityGraph<?> createDynamicEntityGraph(EntityManager em, JpaEnti
*/
static void configureFetchGraphFrom(JpaEntityGraph jpaEntityGraph, EntityGraph<?> entityGraph) {

List<String> attributePaths = new ArrayList<String>(jpaEntityGraph.getAttributePaths());
List<String> attributePaths = new ArrayList<>(jpaEntityGraph.getAttributePaths());

// Sort to ensure that the intermediate entity subgraphs are created accordingly.
Collections.sort(attributePaths);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public DefaultJpaContext(Set<EntityManager> entityManagers) {
Assert.notNull(entityManagers, "EntityManagers must not be null!");
Assert.notEmpty(entityManagers, "EntityManagers must not be empty!");

this.entityManagers = new LinkedMultiValueMap<Class<?>, EntityManager>();
this.entityManagers = new LinkedMultiValueMap<>();

for (EntityManager em : entityManagers) {
for (ManagedType<?> managedType : em.getMetamodel().getManagedTypes()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public abstract class JpaEntityInformationSupport<T, ID> extends AbstractEntityI
*/
public JpaEntityInformationSupport(Class<T> domainClass) {
super(domainClass);
this.metadata = new DefaultJpaEntityMetadata<T>(domainClass);
this.metadata = new DefaultJpaEntityMetadata<>(domainClass);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ public Querydsl(EntityManager em, PathBuilder<?> builder) {
public <T> AbstractJPAQuery<T, JPAQuery<T>> createQuery() {

switch (provider) {
case ECLIPSELINK:
return new JPAQuery<T>(em, EclipseLinkTemplates.DEFAULT);
case HIBERNATE:
return new JPAQuery<T>(em, HQLTemplates.DEFAULT);
case GENERIC_JPA:
default:
return new JPAQuery<T>(em);
case ECLIPSELINK:
return new JPAQuery<>(em, EclipseLinkTemplates.DEFAULT);
case HIBERNATE:
return new JPAQuery<>(em, HQLTemplates.DEFAULT);
case GENERIC_JPA:
default:
return new JPAQuery<>(em);
}
}

Expand Down Expand Up @@ -209,15 +209,15 @@ private NullHandling toQueryDslNullHandling(org.springframework.data.domain.Sort

switch (nullHandling) {

case NULLS_FIRST:
return NullHandling.NullsFirst;
case NULLS_FIRST:
return NullHandling.NullsFirst;

case NULLS_LAST:
return NullHandling.NullsLast;
case NULLS_LAST:
return NullHandling.NullsLast;

case NATIVE:
default:
return NullHandling.Default;
case NATIVE:
default:
return NullHandling.Default;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public QuerydslJpaRepository(JpaEntityInformation<T, ID> entityInformation, Enti
super(entityInformation, entityManager);

this.path = resolver.createPath(entityInformation.getJavaType());
this.builder = new PathBuilder<T>(path.getType(), path.getMetadata());
this.builder = new PathBuilder<>(path.getType(), path.getMetadata());
this.querydsl = new Querydsl(entityManager, builder);
this.entityManager = entityManager;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ public final class BeanDefinitionUtils {
private static final String JNDI_OBJECT_FACTORY_BEAN = "org.springframework.jndi.JndiObjectFactoryBean";
private static final List<Class<?>> EMF_TYPES;

private BeanDefinitionUtils() {}
private BeanDefinitionUtils() {
}

static {

List<Class<?>> types = new ArrayList<Class<?>>();
List<Class<?>> types = new ArrayList<>();
types.add(EntityManagerFactory.class);
types.add(AbstractEntityManagerFactoryBean.class);

Expand Down Expand Up @@ -96,7 +97,7 @@ public static Iterable<String> getEntityManagerFactoryBeanNames(ListableBeanFact
public static Collection<EntityManagerFactoryBeanDefinition> getEntityManagerFactoryBeanDefinitions(
ConfigurableListableBeanFactory beanFactory) {

Set<EntityManagerFactoryBeanDefinition> definitions = new HashSet<EntityManagerFactoryBeanDefinition>();
Set<EntityManagerFactoryBeanDefinition> definitions = new HashSet<>();

for (Class<?> type : EMF_TYPES) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Child {
Long id;

@ManyToMany(mappedBy = "children")
Set<Parent> parents = new HashSet<Parent>();
Set<Parent> parents = new HashSet<>();

/**
* @param parent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class Parent {
static final long serialVersionUID = -89717120680485957L;

@ManyToMany(cascade = CascadeType.ALL)
Set<Child> children = new HashSet<Child>();
Set<Child> children = new HashSet<>();

public Parent add(Child child) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public User(String firstname, String lastname, String emailAddress, Role... role
this.lastname = lastname;
this.emailAddress = emailAddress;
this.active = true;
this.roles = new HashSet<Role>(Arrays.asList(roles));
this.colleagues = new HashSet<User>();
this.attributes = new HashSet<String>();
this.roles = new HashSet<>(Arrays.asList(roles));
this.colleagues = new HashSet<>();
this.attributes = new HashSet<>();
this.createdAt = new Date();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ class JavaConfigUserRepositoryTests extends UserRepositoryTests {
@ImportResource("classpath:infrastructure.xml")
static class Config {

@PersistenceContext EntityManager entityManager;
@Autowired ApplicationContext applicationContext;
@PersistenceContext
EntityManager entityManager;
@Autowired
ApplicationContext applicationContext;

@Bean
public EvaluationContextExtension sampleEvaluationContextExtension() {
Expand All @@ -75,7 +77,7 @@ public UserRepository userRepository() throws Exception {
QueryMethodEvaluationContextProvider evaluationContextProvider = new ExtensionAwareQueryMethodEvaluationContextProvider(
applicationContext);

JpaRepositoryFactoryBean<UserRepository, User, Integer> factory = new JpaRepositoryFactoryBean<UserRepository, User, Integer>(
JpaRepositoryFactoryBean<UserRepository, User, Integer> factory = new JpaRepositoryFactoryBean<>(
UserRepository.class);
factory.setEntityManager(entityManager);
factory.setBeanFactory(applicationContext);
Expand Down Expand Up @@ -111,5 +113,6 @@ void doesNotPickUpJpaRepository() {
@Configuration
@EnableJpaRepositories(basePackageClasses = UserRepository.class)
@ImportResource("classpath:infrastructure.xml")
static class JpaRepositoryConfig {}
static class JpaRepositoryConfig {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@
@Transactional
public class UserRepositoryTests {

@PersistenceContext EntityManager em;
@PersistenceContext
EntityManager em;

// CUT
@Autowired UserRepository repository;
@Autowired
UserRepository repository;

// Test fixture
private User firstUser;
Expand Down Expand Up @@ -298,7 +300,7 @@ void deleteCollectionOfEntitiesById() {
@Test
void deleteEmptyCollectionDoesNotDeleteAnything() {

assertDeleteCallDoesNotDeleteAnything(new ArrayList<User>());
assertDeleteCallDoesNotDeleteAnything(new ArrayList<>());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public CustomGenericJpaRepositoryFactory(EntityManager entityManager) {

JpaEntityInformation<Object, Serializable> entityMetadata = mock(JpaEntityInformation.class);
when(entityMetadata.getJavaType()).thenReturn((Class<Object>) information.getDomainType());
return new CustomGenericJpaRepository<Object, Serializable>(entityMetadata, em);
return new CustomGenericJpaRepository<>(entityMetadata, em);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
import java.util.Arrays;
import java.util.HashSet;

import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
Expand Down Expand Up @@ -99,7 +97,7 @@ void createEntityManagers() {
this.firstEm = firstEmf.createEntityManager();
this.secondEm = secondEmf.createEntityManager();

this.jpaContext = new DefaultJpaContext(new HashSet<EntityManager>(Arrays.asList(firstEm, secondEm)));
this.jpaContext = new DefaultJpaContext(new HashSet<>(Arrays.asList(firstEm, secondEm)));
}

@Test // DATAJPA-669
Expand Down Expand Up @@ -148,8 +146,7 @@ void bootstrapsDefaultJpaContextInSpringContainerWithEntityManagerFromJndi() thr
}

@EnableJpaRepositories
@ComponentScan(includeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = ApplicationComponent.class),
useDefaultFilters = false)
@ComponentScan(includeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = ApplicationComponent.class), useDefaultFilters = false)
static class Config {

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ void rejectsNullDomainType() {
@Test
void returnsConfiguredType() {

DefaultJpaEntityMetadata<Foo> metadata = new DefaultJpaEntityMetadata<Foo>(Foo.class);
DefaultJpaEntityMetadata<Foo> metadata = new DefaultJpaEntityMetadata<>(Foo.class);
assertThat(metadata.getJavaType()).isEqualTo(Foo.class);
}

@Test
void returnsSimpleClassNameAsEntityNameByDefault() {

DefaultJpaEntityMetadata<Foo> metadata = new DefaultJpaEntityMetadata<Foo>(Foo.class);
DefaultJpaEntityMetadata<Foo> metadata = new DefaultJpaEntityMetadata<>(Foo.class);
assertThat(metadata.getEntityName()).isEqualTo(Foo.class.getSimpleName());
}

@Test
void returnsCustomizedEntityNameIfConfigured() {

DefaultJpaEntityMetadata<Bar> metadata = new DefaultJpaEntityMetadata<Bar>(Bar.class);
DefaultJpaEntityMetadata<Bar> metadata = new DefaultJpaEntityMetadata<>(Bar.class);
assertThat(metadata.getEntityName()).isEqualTo("Entity");
}

@Test // DATAJPA-871
void returnsCustomizedEntityNameIfConfiguredViaComposedAnnotation() {

DefaultJpaEntityMetadata<BarWithComposedAnnotation> metadata = new DefaultJpaEntityMetadata<BarWithComposedAnnotation>(
DefaultJpaEntityMetadata<BarWithComposedAnnotation> metadata = new DefaultJpaEntityMetadata<>(
BarWithComposedAnnotation.class);
assertThat(metadata.getEntityName()).isEqualTo("Entity");
}
Expand All @@ -78,11 +78,14 @@ void returnsCustomizedEntityNameIfConfiguredViaComposedAnnotation() {
String entityName();
}

private static class Foo {}
private static class Foo {
}

@Entity(name = "Entity")
static class Bar {}
static class Bar {
}

@CustomEntityAnnotationUsingAliasFor(entityName = "Entity")
private static class BarWithComposedAnnotation {}
private static class BarWithComposedAnnotation {
}
}
Loading