Skip to content

Commit f432ee5

Browse files
author
Julian Kast
committed
Add clone to javaSE SdlFile
1 parent ff9ebd2 commit f432ee5

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlArtwork.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,10 @@ private Image createImageRPC() {
159159
*/
160160
@Override
161161
public SdlArtwork clone() {
162-
try {
163-
SdlArtwork artwork = (SdlArtwork) super.clone();
164-
if (artwork != null) {
165-
artwork.imageRPC = artwork.createImageRPC();
166-
}
162+
SdlArtwork artwork = (SdlArtwork) super.clone();
163+
if (artwork != null) {
164+
artwork.imageRPC = artwork.createImageRPC();
167165
return artwork;
168-
} catch (CloneNotSupportedException e) {
169-
if (DebugTool.isDebugEnabled()) {
170-
throw new RuntimeException("Clone not supported by super class");
171-
}
172166
}
173167
return null;
174168
}

javaSE/javaSE/src/main/java/com/smartdevicelink/managers/file/filetypes/SdlFile.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
import com.smartdevicelink.proxy.rpc.enums.FileType;
3737
import com.smartdevicelink.proxy.rpc.enums.StaticIconName;
38+
import com.smartdevicelink.util.DebugTool;
3839

3940
import java.net.URI;
4041
import java.security.MessageDigest;
@@ -366,4 +367,22 @@ public boolean equals(Object o) {
366367
// return comparison
367368
return hashCode() == o.hashCode();
368369
}
370+
371+
/**
372+
* Creates a deep copy of the object
373+
*
374+
* @return deep copy of the object, null if an exception occurred
375+
*/
376+
@Override
377+
public SdlFile clone() {
378+
try {
379+
SdlFile fileClone = (SdlFile) super.clone();
380+
return fileClone;
381+
} catch (CloneNotSupportedException e) {
382+
if (DebugTool.isDebugEnabled()) {
383+
throw new RuntimeException("Clone not supported by super class");
384+
}
385+
}
386+
return null;
387+
}
369388
}

0 commit comments

Comments
 (0)