You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/09/12 13:15:49 UTC
(commons-jcs) 05/09: Use final
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit 084b1f170866be7ac847817201dd87101af4251f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 09:10:23 2024 -0400
Use final
Remove redundant syntax and whitespace
---
.../commons/jcs/yajcache/util/SerializeUtils.java | 27 +++++++++++-----------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/util/SerializeUtils.java b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/util/SerializeUtils.java
index fc654f7c..bf12bf11 100644
--- a/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/util/SerializeUtils.java
+++ b/commons-jcs3-sandbox/commons-jcs3-yajcache/src/main/java/org/apache/commons/jcs/yajcache/util/SerializeUtils.java
@@ -37,29 +37,28 @@ public enum SerializeUtils {
* @return a duplicate of the given Serializable object,
* short-cutting the deep clone process if possible.
*/
- public <V extends Serializable> V dup(V obj) {
+ public <V extends Serializable> V dup(final V obj) {
Class k = null;
if (obj == null
- || ClassUtils.inst.isImmutable(k=obj.getClass()))
+ || ClassUtils.inst.isImmutable(k=obj.getClass())) {
return obj;
- Class t = k.getComponentType();
+ }
+ final Class t = k.getComponentType();
- if (t != null) {
- // an array.
- if (ClassUtils.inst.isImmutable(t))
- {
- // array elements are immutable.
- // short cut via shallow clone.
- return this.cloneArray(obj);
- }
+ // an array.
+ if ((t != null) && ClassUtils.inst.isImmutable(t))
+ {
+ // array elements are immutable.
+ // short cut via shallow clone.
+ return this.cloneArray(obj);
}
// deep clone.
return (V)SerializationUtils.clone(obj);
}
- private @NonNullable <A> A cloneArray(@NonNullable A a) {
- int len = Array.getLength(a);
- Object result = Array.newInstance(a.getClass().getComponentType(), len);
+ private @NonNullable <A> A cloneArray(@NonNullable final A a) {
+ final int len = Array.getLength(a);
+ final Object result = Array.newInstance(a.getClass().getComponentType(), len);
System.arraycopy(a, 0, result, 0, len);
return (A)result;
}