Skip to content

Commit c98c020

Browse files
committed
Remove near From Query Builder DSL
I'd like to be a little bit more careful here and not add a default method that throws an UnsupportedOperationException. In the meantime, applications can use the filter method like so: LdapQueryBuilder.query().filter(new ProximityFilter("cn", "John Doe")) PR gh-1052
1 parent 058f529 commit c98c020

File tree

3 files changed

+3
-21
lines changed

3 files changed

+3
-21
lines changed

core/src/main/java/org/springframework/ldap/query/ConditionCriteria.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,4 @@ public interface ConditionCriteria {
105105
*/
106106
ConditionCriteria not();
107107

108-
/**
109-
* Appends an {@link org.springframework.ldap.filter.ProximityFilter}.
110-
* @param value the value to compare with.
111-
* @return an ContainerCriteria instance that can be used to continue append more
112-
* criteria or as the LdapQuery instance to be used as instance to e.g.
113-
* {@link org.springframework.ldap.core.LdapOperations#search(LdapQuery, org.springframework.ldap.core.ContextMapper)}.
114-
* @since 3.3
115-
* @see org.springframework.ldap.filter.EqualsFilter
116-
*/
117-
default ContainerCriteria near(String value) {
118-
throw new UnsupportedOperationException();
119-
}
120-
121108
}

core/src/main/java/org/springframework/ldap/query/DefaultConditionCriteria.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.springframework.ldap.filter.LikeFilter;
2424
import org.springframework.ldap.filter.NotFilter;
2525
import org.springframework.ldap.filter.PresentFilter;
26-
import org.springframework.ldap.filter.ProximityFilter;
2726
import org.springframework.ldap.filter.WhitespaceWildcardsFilter;
2827

2928
/**
@@ -73,11 +72,6 @@ public ContainerCriteria isPresent() {
7372
return appendToParent(new PresentFilter(this.attribute));
7473
}
7574

76-
@Override
77-
public ContainerCriteria near(String value) {
78-
return appendToParent(new ProximityFilter(this.attribute, value));
79-
}
80-
8175
private ContainerCriteria appendToParent(Filter filter) {
8276
return this.parent.append(negateIfApplicable(filter));
8377
}

core/src/test/java/org/springframework/ldap/query/LdapQueryBuilderTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2005-2023 the original author or authors.
2+
* Copyright 2005-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import org.junit.Test;
2020

21+
import org.springframework.ldap.filter.ProximityFilter;
2122
import org.springframework.ldap.support.LdapUtils;
2223

2324
import static org.assertj.core.api.Assertions.assertThat;
@@ -75,7 +76,7 @@ public void buildPresent() {
7576

7677
@Test
7778
public void buildProximity() {
78-
LdapQuery result = LdapQueryBuilder.query().where("cn").near("John Doe");
79+
LdapQuery result = LdapQueryBuilder.query().filter(new ProximityFilter("cn", "John Doe"));
7980

8081
assertThat(result.filter().encode()).isEqualTo("(cn~=John Doe)");
8182
}

0 commit comments

Comments
 (0)