From ade8715b85cc4205ba2420cca24e253891a13540 Mon Sep 17 00:00:00 2001 From: GuangrongFu Date: Fri, 17 Aug 2018 16:24:55 +0800 Subject: [PATCH] Added a clone Method to a Class Change-Id: Ifed18ae35ef12148dd4d3d7b9f5fc81999e2548e Issue-ID: HOLMES-159 Signed-off-by: GuangrongFu --- .../holmes/common/api/entity/CorrelationRule.java | 55 +++++++++++++++------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/CorrelationRule.java b/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/CorrelationRule.java index d7965c5..acfae35 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/CorrelationRule.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/CorrelationRule.java @@ -1,12 +1,12 @@ /** * Copyright 2017 ZTE Corporation. - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,38 +16,30 @@ package org.onap.holmes.common.api.entity; import com.google.gson.annotations.SerializedName; + +import java.io.Closeable; import java.util.Date; import java.util.Properties; + import lombok.Getter; import lombok.Setter; @Getter @Setter -public class CorrelationRule { - +public class CorrelationRule implements Cloneable { @SerializedName(value = "ruleid") private String rid; @SerializedName(value = "rulename") private String name; - private String description; - private int enabled; - private long templateID; - private String engineID; - private String engineType; - private String creator; - private String modifier; - private Properties params; - private String content; - private String vendor; @SerializedName(value = "createtime") private Date createTime; @@ -59,4 +51,35 @@ public class CorrelationRule { private String closedControlLoopName; @SerializedName(value = "engineinstance") private String engineInstance; + + @Override + public Object clone() { + CorrelationRule r = null; + try { + r = (CorrelationRule) super.clone(); + } catch (CloneNotSupportedException e) { + // This will never happen. + throw new InternalError(e); + } + + r.rid = rid == null ? null : rid; + r.name = name == null ? null : name; + r.description = description == null ? null : description; + r.enabled = enabled; + r.templateID = templateID; + r.engineID = engineID == null ? null : engineID; + r.engineType = engineType == null ? null : engineType; + r.creator = creator == null ? null : creator; + r.modifier = modifier == null ? null : modifier; + r.params = params == null ? null : (Properties) params.clone(); + r.content = content == null ? null : content; + r.vendor = vendor == null ? null : vendor; + r.createTime = createTime == null ? null : (Date) createTime.clone(); + r.updateTime = updateTime == null ? null : (Date) updateTime.clone(); + r.packageName = packageName == null ? null : packageName; + r.closedControlLoopName = closedControlLoopName == null ? null : closedControlLoopName; + r.engineInstance = engineInstance == null ? null : engineInstance; + + return r; + } } -- 2.16.6