* ONAP Policy Model
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.models.tosca.simple.concepts;
import com.google.gson.annotations.SerializedName;
-
import java.time.Duration;
import java.util.List;
-
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
-
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
-
import org.apache.commons.lang3.ObjectUtils;
-import org.onap.policy.common.utils.validation.Assertions;
import org.onap.policy.common.utils.validation.ParameterValidationUtils;
import org.onap.policy.models.base.PfConcept;
import org.onap.policy.models.base.PfKey;
*/
public JpaToscaTrigger(final JpaToscaTrigger copyConcept) {
super(copyConcept);
+ this.key = new PfReferenceKey(copyConcept.key);
+ this.description = copyConcept.description;
+ this.eventType = copyConcept.eventType;
+ this.schedule = (copyConcept.schedule != null ? new JpaToscaTimeInterval(copyConcept.schedule) : null);
+ this.targetFilter =
+ (copyConcept.targetFilter != null ? new JpaToscaEventFilter(copyConcept.targetFilter) : null);
+ this.condition = copyConcept.condition;
+ this.constraint = copyConcept.constraint;
+ this.period = copyConcept.period;
+ this.evaluations = copyConcept.evaluations;
+ this.method = copyConcept.method;
+ this.action = copyConcept.action;
}
@Override
return 0;
}
if (getClass() != otherConcept.getClass()) {
- return this.hashCode() - otherConcept.hashCode();
+ return getClass().getName().compareTo(otherConcept.getClass().getName());
}
final JpaToscaTrigger other = (JpaToscaTrigger) otherConcept;
- if (!key.equals(other.key)) {
- return key.compareTo(other.key);
+ int result = key.compareTo(other.key);
+ if (result != 0) {
+ return result;
}
return compareFields(other);
}
/**
- * Compare the fields of this ToscaTrigger object with the fields of the other ToscaProperty
- * object.
+ * Compare the fields of this ToscaTrigger object with the fields of the other ToscaProperty object.
*
* @param other the other ToscaTrigger object
*/
return ObjectUtils.compare(action, other.action);
}
-
- @Override
- public PfConcept copyTo(@NonNull final PfConcept target) {
- Assertions.instanceOf(target, JpaToscaTrigger.class);
-
- final JpaToscaTrigger copy = ((JpaToscaTrigger) target);
- copy.setKey(new PfReferenceKey(key));
- copy.setDescription(description);
- copy.setEventType(eventType);
- copy.setSchedule(schedule != null ? new JpaToscaTimeInterval(schedule) : null);
- copy.setTargetFilter(targetFilter != null ? new JpaToscaEventFilter(targetFilter) : null);
- copy.setCondition(condition);
- copy.setConstraint(constraint);
- copy.setPeriod(period);
- copy.setEvaluations(evaluations);
- copy.setMethod(method);
- copy.setAction(action);
-
- return copy;
- }
}