Skip to content

Commit

Permalink
Simplify condition in some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ngocnhan-tran1996 authored and jzheaux committed Oct 25, 2024
1 parent e76de93 commit ab93541
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,8 @@ public boolean equals(final Object obj) {
if (!super.equals(obj)) {
return false;
}
if (obj instanceof CasAuthenticationToken) {
CasAuthenticationToken test = (CasAuthenticationToken) obj;
if (!this.assertion.equals(test.getAssertion())) {
return false;
}
if (this.getKeyHash() != test.getKeyHash()) {
return false;
}
return true;
if (obj instanceof CasAuthenticationToken test) {
return this.assertion.equals(test.getAssertion()) && this.getKeyHash() == test.getKeyHash();
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,12 +43,9 @@ public Set<ConvertiblePair> getConvertibleTypes() {

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
if (targetType.getElementTypeDescriptor() == null
|| targetType.getElementTypeDescriptor().getType().equals(String.class) || sourceType == null
|| ClassUtils.isAssignable(sourceType.getType(), targetType.getElementTypeDescriptor().getType())) {
return true;
}
return false;
TypeDescriptor typeDescriptor = targetType.getElementTypeDescriptor();
return typeDescriptor == null || typeDescriptor.getType().equals(String.class) || sourceType == null
|| ClassUtils.isAssignable(sourceType.getType(), typeDescriptor.getType());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ public Set<ConvertiblePair> getConvertibleTypes() {

@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
if (targetType.getElementTypeDescriptor() == null
|| targetType.getMapKeyTypeDescriptor().getType().equals(String.class)) {
return true;
}
return false;
return targetType.getElementTypeDescriptor() == null
|| targetType.getMapKeyTypeDescriptor().getType().equals(String.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,8 @@ private boolean skipDispatch(HttpServletRequest request) {
if (DispatcherType.ERROR.equals(request.getDispatcherType()) && !this.filterErrorDispatch) {
return true;
}
if (DispatcherType.ASYNC.equals(request.getDispatcherType()) && !this.filterAsyncDispatch) {
return true;
}
return false;

return DispatcherType.ASYNC.equals(request.getDispatcherType()) && !this.filterAsyncDispatch;
}

private boolean isApplied(HttpServletRequest request) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -87,10 +87,7 @@ private boolean containsInvalidUrlEncodedSlash(String uri) {
if (this.allowUrlEncodedSlash || uri == null) {
return false;
}
if (uri.contains("%2f") || uri.contains("%2F")) {
return true;
}
return false;
return uri.contains("%2f") || uri.contains("%2F");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,7 @@ private static boolean decodedUrlContains(HttpServletRequest request, String val
if (valueContains(request.getServletPath(), value)) {
return true;
}
if (valueContains(request.getPathInfo(), value)) {
return true;
}
return false;
return valueContains(request.getPathInfo(), value);
}

private static boolean containsOnlyPrintableAsciiCharacters(String uri) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -354,10 +354,7 @@ private boolean propertyEquals(Object arg1, Object arg2) {
if (arg1 == null || arg2 == null) {
return false;
}
if (arg1.equals(arg2)) {
return true;
}
return false;
return arg1.equals(arg2);
}

@Override
Expand Down

0 comments on commit ab93541

Please sign in to comment.