Skip to content

Commit b190a7a

Browse files
Added EclipseStoreRepository-Interfaces and tests for it
1 parent 75dce51 commit b190a7a

18 files changed

+818
-9
lines changed

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/config/EclipseStoreRepositoryConfigurationExtension.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818
import java.lang.annotation.Annotation;
1919
import java.util.Collection;
2020
import java.util.Collections;
21+
import java.util.List;
2122

2223
import jakarta.annotation.Nonnull;
2324

2425
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
2526
import org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport;
2627

27-
import software.xdev.spring.data.eclipse.store.repository.EclipseStoreRepository;
28+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreCrudRepository;
29+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListCrudRepository;
30+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListPagingAndSortingRepositoryRepository;
31+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStorePagingAndSortingRepositoryRepository;
32+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository;
2833
import software.xdev.spring.data.eclipse.store.repository.support.EclipseStoreRepositoryFactoryBean;
2934

3035

@@ -75,6 +80,12 @@ public Collection<Class<? extends Annotation>> getIdentifyingAnnotations()
7580
@Nonnull
7681
protected Collection<Class<?>> getIdentifyingTypes()
7782
{
78-
return Collections.singleton(EclipseStoreRepository.class);
83+
return List.of(
84+
EclipseStoreRepository.class,
85+
EclipseStorePagingAndSortingRepositoryRepository.class,
86+
EclipseStoreListPagingAndSortingRepositoryRepository.class,
87+
EclipseStoreCrudRepository.class,
88+
EclipseStoreListCrudRepository.class
89+
);
7990
}
8091
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.repository.interfaces;
17+
18+
import org.springframework.data.repository.CrudRepository;
19+
import org.springframework.data.repository.NoRepositoryBean;
20+
21+
22+
@NoRepositoryBean
23+
public interface EclipseStoreCrudRepository<T, ID> extends CrudRepository<T, ID>
24+
{
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.repository.interfaces;
17+
18+
import org.springframework.data.repository.ListCrudRepository;
19+
import org.springframework.data.repository.NoRepositoryBean;
20+
21+
22+
@NoRepositoryBean
23+
public interface EclipseStoreListCrudRepository<T, ID> extends ListCrudRepository<T, ID>
24+
{
25+
}

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/EclipseStoreRepository.java renamed to spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/interfaces/EclipseStoreListPagingAndSortingRepositoryRepository.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package software.xdev.spring.data.eclipse.store.repository;
16+
package software.xdev.spring.data.eclipse.store.repository.interfaces;
1717

18-
import org.springframework.data.repository.ListCrudRepository;
1918
import org.springframework.data.repository.ListPagingAndSortingRepository;
2019
import org.springframework.data.repository.NoRepositoryBean;
2120

2221

2322
@NoRepositoryBean
24-
public interface EclipseStoreRepository<T, ID>
25-
extends ListCrudRepository<T, ID>, ListPagingAndSortingRepository<T, ID>
23+
public interface EclipseStoreListPagingAndSortingRepositoryRepository<T, ID>
24+
extends ListPagingAndSortingRepository<T, ID>
2625
{
2726
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.repository.interfaces;
17+
18+
import org.springframework.data.repository.NoRepositoryBean;
19+
import org.springframework.data.repository.PagingAndSortingRepository;
20+
21+
22+
@NoRepositoryBean
23+
public interface EclipseStorePagingAndSortingRepositoryRepository<T, ID>
24+
extends PagingAndSortingRepository<T, ID>
25+
{
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.repository.interfaces;
17+
18+
import org.springframework.data.repository.NoRepositoryBean;
19+
import org.springframework.data.repository.Repository;
20+
21+
22+
@NoRepositoryBean
23+
public interface EclipseStoreRepository<T, ID> extends Repository<T, ID>
24+
{
25+
}

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/SimpleEclipseStoreRepository.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,37 @@
2323
import java.util.Set;
2424
import java.util.stream.Collectors;
2525

26+
import jakarta.annotation.Nonnull;
27+
2628
import org.slf4j.Logger;
2729
import org.slf4j.LoggerFactory;
2830
import org.springframework.data.domain.Page;
2931
import org.springframework.data.domain.Pageable;
3032
import org.springframework.data.domain.Sort;
3133

32-
import jakarta.annotation.Nonnull;
3334
import software.xdev.spring.data.eclipse.store.exceptions.FieldAccessReflectionException;
3435
import software.xdev.spring.data.eclipse.store.exceptions.NoIdFieldFoundException;
35-
import software.xdev.spring.data.eclipse.store.repository.EclipseStoreRepository;
3636
import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage;
3737
import software.xdev.spring.data.eclipse.store.repository.access.modifier.FieldAccessModifier;
38+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreCrudRepository;
39+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListCrudRepository;
40+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListPagingAndSortingRepositoryRepository;
41+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStorePagingAndSortingRepositoryRepository;
42+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository;
3843
import software.xdev.spring.data.eclipse.store.repository.query.criteria.Criteria;
3944
import software.xdev.spring.data.eclipse.store.repository.query.executors.ListQueryExecutor;
4045
import software.xdev.spring.data.eclipse.store.repository.query.executors.PageableQueryExecutor;
4146
import software.xdev.spring.data.eclipse.store.repository.support.copier.working.WorkingCopier;
4247
import software.xdev.spring.data.eclipse.store.repository.support.copier.working.WorkingCopierResult;
4348

4449

45-
public class SimpleEclipseStoreRepository<T, ID> implements EclipseStoreRepository<T, ID>
50+
public class SimpleEclipseStoreRepository<T, ID>
51+
implements
52+
EclipseStoreRepository<T, ID>,
53+
EclipseStorePagingAndSortingRepositoryRepository<T, ID>,
54+
EclipseStoreListPagingAndSortingRepositoryRepository<T, ID>,
55+
EclipseStoreCrudRepository<T, ID>,
56+
EclipseStoreListCrudRepository<T, ID>
4657
{
4758
private static final Logger LOG = LoggerFactory.getLogger(SimpleEclipseStoreRepository.class);
4859
private final EclipseStoreStorage storage;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.repositories.interfaces;
17+
18+
import java.util.List;
19+
import java.util.Objects;
20+
21+
22+
public class CustomerCrud
23+
{
24+
private String firstName;
25+
private String lastName;
26+
27+
public CustomerCrud(final String firstName, final String lastName)
28+
{
29+
this.firstName = firstName;
30+
this.lastName = lastName;
31+
}
32+
33+
public String getFirstName()
34+
{
35+
return this.firstName;
36+
}
37+
38+
public void setFirstName(final String firstName)
39+
{
40+
this.firstName = firstName;
41+
}
42+
43+
public String getLastName()
44+
{
45+
return this.lastName;
46+
}
47+
48+
public void setLastName(final String lastName)
49+
{
50+
this.lastName = lastName;
51+
}
52+
53+
@Override
54+
public String toString()
55+
{
56+
return String.format(
57+
"Customer[firstName='%s', lastName='%s']",
58+
this.firstName, this.lastName);
59+
}
60+
61+
@Override
62+
public boolean equals(final Object o)
63+
{
64+
if(this == o)
65+
{
66+
return true;
67+
}
68+
if(o == null || this.getClass() != o.getClass())
69+
{
70+
return false;
71+
}
72+
final CustomerCrud customer = (CustomerCrud)o;
73+
return Objects.equals(this.firstName, customer.firstName) && Objects.equals(
74+
this.lastName,
75+
customer.lastName);
76+
}
77+
78+
@Override
79+
public int hashCode()
80+
{
81+
return Objects.hash(this.firstName, this.lastName);
82+
}
83+
84+
@SuppressWarnings("OptionalGetWithoutIsPresent")
85+
public static CustomerCrud getCustomerWithFirstName(
86+
final List<CustomerCrud> customers,
87+
final String firstName)
88+
{
89+
return customers.stream().filter(customer -> customer.getFirstName().equals(firstName)).findFirst().get();
90+
}
91+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.repositories.interfaces;
17+
18+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreCrudRepository;
19+
20+
21+
public interface CustomerEclipseStoreCrudRepository extends EclipseStoreCrudRepository<CustomerCrud, String>
22+
{
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.repositories.interfaces;
17+
18+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListCrudRepository;
19+
20+
21+
public interface CustomerEclipseStoreListCrudRepository extends EclipseStoreListCrudRepository<CustomerListCrud, String>
22+
{
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.repositories.interfaces;
17+
18+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreListPagingAndSortingRepositoryRepository;
19+
20+
21+
public interface CustomerEclipseStoreListPagingAndSortingRepository extends
22+
EclipseStoreListPagingAndSortingRepositoryRepository<CustomerListPagingAndSorting, String>
23+
{
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.repositories.interfaces;
17+
18+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStorePagingAndSortingRepositoryRepository;
19+
20+
21+
public interface CustomerEclipseStorePagingAndSortingRepository
22+
extends EclipseStorePagingAndSortingRepositoryRepository<CustomerPagingAndSorting, String>
23+
{
24+
}

0 commit comments

Comments
 (0)