Skip to content

Commit 8adf061

Browse files
Haaroleanjzheaux
authored andcommitted
Chore: polishing, javadocs
1 parent 3666509 commit 8adf061

File tree

1 file changed

+47
-75
lines changed

1 file changed

+47
-75
lines changed

core/src/main/java/org/springframework/ldap/core/LdapTemplate.java

Lines changed: 47 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -828,11 +828,9 @@ public Object executeWithContext(DirContext ctx) throws javax.naming.NamingExcep
828828
*/
829829
@Override
830830
public <T> T lookup(final Name dn, final AttributesMapper<T> mapper) {
831-
return executeReadOnly(new ContextExecutor<T>() {
832-
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
833-
Attributes attributes = ctx.getAttributes(dn);
834-
return mapper.mapFromAttributes(attributes);
835-
}
831+
return executeReadOnly(ctx -> {
832+
Attributes attributes = ctx.getAttributes(dn);
833+
return mapper.mapFromAttributes(attributes);
836834
});
837835
}
838836

@@ -842,11 +840,9 @@ public T executeWithContext(DirContext ctx) throws javax.naming.NamingException
842840
@Override
843841
public <T> T lookup(final String dn, final AttributesMapper<T> mapper) {
844842

845-
return executeReadOnly(new ContextExecutor<T>() {
846-
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
847-
Attributes attributes = ctx.getAttributes(dn);
848-
return mapper.mapFromAttributes(attributes);
849-
}
843+
return executeReadOnly(ctx -> {
844+
Attributes attributes = ctx.getAttributes(dn);
845+
return mapper.mapFromAttributes(attributes);
850846
});
851847
}
852848

@@ -855,11 +851,9 @@ public T executeWithContext(DirContext ctx) throws javax.naming.NamingException
855851
*/
856852
@Override
857853
public <T> T lookup(final Name dn, final ContextMapper<T> mapper) {
858-
return executeReadOnly(new ContextExecutor<T>() {
859-
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
860-
Object object = ctx.lookup(dn);
861-
return mapper.mapFromContext(object);
862-
}
854+
return executeReadOnly(ctx -> {
855+
Object object = ctx.lookup(dn);
856+
return mapper.mapFromContext(object);
863857
});
864858
}
865859

@@ -868,11 +862,9 @@ public T executeWithContext(DirContext ctx) throws javax.naming.NamingException
868862
*/
869863
@Override
870864
public <T> T lookup(final String dn, final ContextMapper<T> mapper) {
871-
return executeReadOnly(new ContextExecutor<T>() {
872-
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
873-
Object object = ctx.lookup(dn);
874-
return mapper.mapFromContext(object);
875-
}
865+
return executeReadOnly(ctx -> {
866+
Object object = ctx.lookup(dn);
867+
return mapper.mapFromContext(object);
876868
});
877869
}
878870

@@ -881,11 +873,9 @@ public T executeWithContext(DirContext ctx) throws javax.naming.NamingException
881873
*/
882874
@Override
883875
public <T> T lookup(final Name dn, final String[] attributes, final AttributesMapper<T> mapper) {
884-
return executeReadOnly(new ContextExecutor<T>() {
885-
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
886-
Attributes filteredAttributes = ctx.getAttributes(dn, attributes);
887-
return mapper.mapFromAttributes(filteredAttributes);
888-
}
876+
return executeReadOnly(ctx -> {
877+
Attributes filteredAttributes = ctx.getAttributes(dn, attributes);
878+
return mapper.mapFromAttributes(filteredAttributes);
889879
});
890880
}
891881

@@ -894,11 +884,9 @@ public T executeWithContext(DirContext ctx) throws javax.naming.NamingException
894884
*/
895885
@Override
896886
public <T> T lookup(final String dn, final String[] attributes, final AttributesMapper<T> mapper) {
897-
return executeReadOnly(new ContextExecutor<T>() {
898-
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
899-
Attributes filteredAttributes = ctx.getAttributes(dn, attributes);
900-
return mapper.mapFromAttributes(filteredAttributes);
901-
}
887+
return executeReadOnly(ctx -> {
888+
Attributes filteredAttributes = ctx.getAttributes(dn, attributes);
889+
return mapper.mapFromAttributes(filteredAttributes);
902890
});
903891
}
904892

@@ -907,12 +895,10 @@ public T executeWithContext(DirContext ctx) throws javax.naming.NamingException
907895
*/
908896
@Override
909897
public <T> T lookup(final Name dn, final String[] attributes, final ContextMapper<T> mapper) {
910-
return executeReadOnly(new ContextExecutor<T>() {
911-
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
912-
Attributes filteredAttributes = ctx.getAttributes(dn, attributes);
913-
DirContextAdapter contextAdapter = new DirContextAdapter(filteredAttributes, dn);
914-
return mapper.mapFromContext(contextAdapter);
915-
}
898+
return executeReadOnly(ctx -> {
899+
Attributes filteredAttributes = ctx.getAttributes(dn, attributes);
900+
DirContextAdapter contextAdapter = new DirContextAdapter(filteredAttributes, dn);
901+
return mapper.mapFromContext(contextAdapter);
916902
});
917903
}
918904

@@ -921,13 +907,11 @@ public T executeWithContext(DirContext ctx) throws javax.naming.NamingException
921907
*/
922908
@Override
923909
public <T> T lookup(final String dn, final String[] attributes, final ContextMapper<T> mapper) {
924-
return executeReadOnly(new ContextExecutor<T>() {
925-
public T executeWithContext(DirContext ctx) throws javax.naming.NamingException {
926-
Attributes filteredAttributes = ctx.getAttributes(dn, attributes);
927-
LdapName name = LdapUtils.newLdapName(dn);
928-
DirContextAdapter contextAdapter = new DirContextAdapter(filteredAttributes, name);
929-
return mapper.mapFromContext(contextAdapter);
930-
}
910+
return executeReadOnly(ctx -> {
911+
Attributes filteredAttributes = ctx.getAttributes(dn, attributes);
912+
LdapName name = LdapUtils.newLdapName(dn);
913+
DirContextAdapter contextAdapter = new DirContextAdapter(filteredAttributes, name);
914+
return mapper.mapFromContext(contextAdapter);
931915
});
932916
}
933917

@@ -962,11 +946,9 @@ public Object executeWithContext(DirContext ctx) throws javax.naming.NamingExcep
962946
*/
963947
@Override
964948
public void bind(final Name dn, final Object obj, final Attributes attributes) {
965-
executeReadWrite(new ContextExecutor<Object>() {
966-
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
967-
ctx.bind(dn, obj, attributes);
968-
return null;
969-
}
949+
executeReadWrite(ctx -> {
950+
ctx.bind(dn, obj, attributes);
951+
return null;
970952
});
971953
}
972954

@@ -975,11 +957,9 @@ public Object executeWithContext(DirContext ctx) throws javax.naming.NamingExcep
975957
*/
976958
@Override
977959
public void bind(final String dn, final Object obj, final Attributes attributes) {
978-
executeReadWrite(new ContextExecutor<Object>() {
979-
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
980-
ctx.bind(dn, obj, attributes);
981-
return null;
982-
}
960+
executeReadWrite(ctx -> {
961+
ctx.bind(dn, obj, attributes);
962+
return null;
983963
});
984964
}
985965

@@ -1026,38 +1006,30 @@ public void unbind(final String dn, boolean recursive) {
10261006
}
10271007

10281008
private void doUnbind(final Name dn) {
1029-
executeReadWrite(new ContextExecutor<Object>() {
1030-
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
1031-
ctx.unbind(dn);
1032-
return null;
1033-
}
1009+
executeReadWrite(ctx -> {
1010+
ctx.unbind(dn);
1011+
return null;
10341012
});
10351013
}
10361014

10371015
private void doUnbind(final String dn) {
1038-
executeReadWrite(new ContextExecutor<Object>() {
1039-
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
1040-
ctx.unbind(dn);
1041-
return null;
1042-
}
1016+
executeReadWrite(ctx -> {
1017+
ctx.unbind(dn);
1018+
return null;
10431019
});
10441020
}
10451021

10461022
private void doUnbindRecursively(final Name dn) {
1047-
executeReadWrite(new ContextExecutor<Object>() {
1048-
public Object executeWithContext(DirContext ctx) {
1049-
deleteRecursively(ctx, LdapUtils.newLdapName(dn));
1050-
return null;
1051-
}
1023+
executeReadWrite(ctx -> {
1024+
deleteRecursively(ctx, LdapUtils.newLdapName(dn));
1025+
return null;
10521026
});
10531027
}
10541028

10551029
private void doUnbindRecursively(final String dn) {
1056-
executeReadWrite(new ContextExecutor<Object>() {
1057-
public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
1058-
deleteRecursively(ctx, LdapUtils.newLdapName(dn));
1059-
return null;
1060-
}
1030+
executeReadWrite(ctx -> {
1031+
deleteRecursively(ctx, LdapUtils.newLdapName(dn));
1032+
return null;
10611033
});
10621034
}
10631035

@@ -1897,15 +1869,15 @@ private enum AuthenticationStatus {
18971869
*/
18981870
UNDEFINED_FAILURE(false);
18991871

1900-
private boolean success;
1872+
private final boolean success;
19011873

19021874
AuthenticationStatus(boolean success) {
19031875
this.success = success;
19041876
}
19051877

19061878
/**
19071879
* Return true if the authentication attempt was successful
1908-
* @return
1880+
* @return true if the authentication attempt was successful
19091881
*/
19101882
public boolean isSuccess() {
19111883
return this.success;

0 commit comments

Comments
 (0)