cdm.product.template.CancellationEvent Maven / Gradle / Ivy
package cdm.product.template;
import cdm.product.template.CancellationEvent;
import cdm.product.template.CancellationEvent.CancellationEventBuilder;
import cdm.product.template.CancellationEvent.CancellationEventBuilderImpl;
import cdm.product.template.CancellationEvent.CancellationEventImpl;
import cdm.product.template.meta.CancellationEventMeta;
import com.rosetta.model.lib.GlobalKey;
import com.rosetta.model.lib.GlobalKey.GlobalKeyBuilder;
import com.rosetta.model.lib.RosettaModelObject;
import com.rosetta.model.lib.RosettaModelObjectBuilder;
import com.rosetta.model.lib.annotations.RosettaAttribute;
import com.rosetta.model.lib.annotations.RosettaDataType;
import com.rosetta.model.lib.meta.RosettaMetaData;
import com.rosetta.model.lib.path.RosettaPath;
import com.rosetta.model.lib.process.BuilderMerger;
import com.rosetta.model.lib.process.BuilderProcessor;
import com.rosetta.model.lib.process.Processor;
import com.rosetta.model.lib.records.Date;
import com.rosetta.model.metafields.MetaFields;
import java.util.Objects;
import static java.util.Optional.ofNullable;
/**
* The adjusted dates for a specific cancellation date, including the adjusted exercise date and adjusted termination date.
* @version 6.0.0-dev.82
*/
@RosettaDataType(value="CancellationEvent", builder=CancellationEvent.CancellationEventBuilderImpl.class, version="6.0.0-dev.82")
public interface CancellationEvent extends RosettaModelObject, GlobalKey {
CancellationEventMeta metaData = new CancellationEventMeta();
/*********************** Getter Methods ***********************/
/**
* The date on which option exercise takes place. This date should already be adjusted for any applicable business day convention.
*/
Date getAdjustedExerciseDate();
/**
* The early termination date that is applicable if an early termination provision is exercised. This date should already be adjusted for any applicable business day convention.
*/
Date getAdjustedEarlyTerminationDate();
MetaFields getMeta();
/*********************** Build Methods ***********************/
CancellationEvent build();
CancellationEvent.CancellationEventBuilder toBuilder();
static CancellationEvent.CancellationEventBuilder builder() {
return new CancellationEvent.CancellationEventBuilderImpl();
}
/*********************** Utility Methods ***********************/
@Override
default RosettaMetaData extends CancellationEvent> metaData() {
return metaData;
}
@Override
default Class extends CancellationEvent> getType() {
return CancellationEvent.class;
}
@Override
default void process(RosettaPath path, Processor processor) {
processor.processBasic(path.newSubPath("adjustedExerciseDate"), Date.class, getAdjustedExerciseDate(), this);
processor.processBasic(path.newSubPath("adjustedEarlyTerminationDate"), Date.class, getAdjustedEarlyTerminationDate(), this);
processRosetta(path.newSubPath("meta"), processor, MetaFields.class, getMeta());
}
/*********************** Builder Interface ***********************/
interface CancellationEventBuilder extends CancellationEvent, RosettaModelObjectBuilder {
MetaFields.MetaFieldsBuilder getOrCreateMeta();
MetaFields.MetaFieldsBuilder getMeta();
CancellationEvent.CancellationEventBuilder setAdjustedExerciseDate(Date adjustedExerciseDate);
CancellationEvent.CancellationEventBuilder setAdjustedEarlyTerminationDate(Date adjustedEarlyTerminationDate);
CancellationEvent.CancellationEventBuilder setMeta(MetaFields meta);
@Override
default void process(RosettaPath path, BuilderProcessor processor) {
processor.processBasic(path.newSubPath("adjustedExerciseDate"), Date.class, getAdjustedExerciseDate(), this);
processor.processBasic(path.newSubPath("adjustedEarlyTerminationDate"), Date.class, getAdjustedEarlyTerminationDate(), this);
processRosetta(path.newSubPath("meta"), processor, MetaFields.MetaFieldsBuilder.class, getMeta());
}
CancellationEvent.CancellationEventBuilder prune();
}
/*********************** Immutable Implementation of CancellationEvent ***********************/
class CancellationEventImpl implements CancellationEvent {
private final Date adjustedExerciseDate;
private final Date adjustedEarlyTerminationDate;
private final MetaFields meta;
protected CancellationEventImpl(CancellationEvent.CancellationEventBuilder builder) {
this.adjustedExerciseDate = builder.getAdjustedExerciseDate();
this.adjustedEarlyTerminationDate = builder.getAdjustedEarlyTerminationDate();
this.meta = ofNullable(builder.getMeta()).map(f->f.build()).orElse(null);
}
@Override
@RosettaAttribute("adjustedExerciseDate")
public Date getAdjustedExerciseDate() {
return adjustedExerciseDate;
}
@Override
@RosettaAttribute("adjustedEarlyTerminationDate")
public Date getAdjustedEarlyTerminationDate() {
return adjustedEarlyTerminationDate;
}
@Override
@RosettaAttribute("meta")
public MetaFields getMeta() {
return meta;
}
@Override
public CancellationEvent build() {
return this;
}
@Override
public CancellationEvent.CancellationEventBuilder toBuilder() {
CancellationEvent.CancellationEventBuilder builder = builder();
setBuilderFields(builder);
return builder;
}
protected void setBuilderFields(CancellationEvent.CancellationEventBuilder builder) {
ofNullable(getAdjustedExerciseDate()).ifPresent(builder::setAdjustedExerciseDate);
ofNullable(getAdjustedEarlyTerminationDate()).ifPresent(builder::setAdjustedEarlyTerminationDate);
ofNullable(getMeta()).ifPresent(builder::setMeta);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
CancellationEvent _that = getType().cast(o);
if (!Objects.equals(adjustedExerciseDate, _that.getAdjustedExerciseDate())) return false;
if (!Objects.equals(adjustedEarlyTerminationDate, _that.getAdjustedEarlyTerminationDate())) return false;
if (!Objects.equals(meta, _that.getMeta())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (adjustedExerciseDate != null ? adjustedExerciseDate.hashCode() : 0);
_result = 31 * _result + (adjustedEarlyTerminationDate != null ? adjustedEarlyTerminationDate.hashCode() : 0);
_result = 31 * _result + (meta != null ? meta.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "CancellationEvent {" +
"adjustedExerciseDate=" + this.adjustedExerciseDate + ", " +
"adjustedEarlyTerminationDate=" + this.adjustedEarlyTerminationDate + ", " +
"meta=" + this.meta +
'}';
}
}
/*********************** Builder Implementation of CancellationEvent ***********************/
class CancellationEventBuilderImpl implements CancellationEvent.CancellationEventBuilder, GlobalKeyBuilder {
protected Date adjustedExerciseDate;
protected Date adjustedEarlyTerminationDate;
protected MetaFields.MetaFieldsBuilder meta;
public CancellationEventBuilderImpl() {
}
@Override
@RosettaAttribute("adjustedExerciseDate")
public Date getAdjustedExerciseDate() {
return adjustedExerciseDate;
}
@Override
@RosettaAttribute("adjustedEarlyTerminationDate")
public Date getAdjustedEarlyTerminationDate() {
return adjustedEarlyTerminationDate;
}
@Override
@RosettaAttribute("meta")
public MetaFields.MetaFieldsBuilder getMeta() {
return meta;
}
@Override
public MetaFields.MetaFieldsBuilder getOrCreateMeta() {
MetaFields.MetaFieldsBuilder result;
if (meta!=null) {
result = meta;
}
else {
result = meta = MetaFields.builder();
}
return result;
}
@Override
@RosettaAttribute("adjustedExerciseDate")
public CancellationEvent.CancellationEventBuilder setAdjustedExerciseDate(Date adjustedExerciseDate) {
this.adjustedExerciseDate = adjustedExerciseDate==null?null:adjustedExerciseDate;
return this;
}
@Override
@RosettaAttribute("adjustedEarlyTerminationDate")
public CancellationEvent.CancellationEventBuilder setAdjustedEarlyTerminationDate(Date adjustedEarlyTerminationDate) {
this.adjustedEarlyTerminationDate = adjustedEarlyTerminationDate==null?null:adjustedEarlyTerminationDate;
return this;
}
@Override
@RosettaAttribute("meta")
public CancellationEvent.CancellationEventBuilder setMeta(MetaFields meta) {
this.meta = meta==null?null:meta.toBuilder();
return this;
}
@Override
public CancellationEvent build() {
return new CancellationEvent.CancellationEventImpl(this);
}
@Override
public CancellationEvent.CancellationEventBuilder toBuilder() {
return this;
}
@SuppressWarnings("unchecked")
@Override
public CancellationEvent.CancellationEventBuilder prune() {
if (meta!=null && !meta.prune().hasData()) meta = null;
return this;
}
@Override
public boolean hasData() {
if (getAdjustedExerciseDate()!=null) return true;
if (getAdjustedEarlyTerminationDate()!=null) return true;
return false;
}
@SuppressWarnings("unchecked")
@Override
public CancellationEvent.CancellationEventBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
CancellationEvent.CancellationEventBuilder o = (CancellationEvent.CancellationEventBuilder) other;
merger.mergeRosetta(getMeta(), o.getMeta(), this::setMeta);
merger.mergeBasic(getAdjustedExerciseDate(), o.getAdjustedExerciseDate(), this::setAdjustedExerciseDate);
merger.mergeBasic(getAdjustedEarlyTerminationDate(), o.getAdjustedEarlyTerminationDate(), this::setAdjustedEarlyTerminationDate);
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
CancellationEvent _that = getType().cast(o);
if (!Objects.equals(adjustedExerciseDate, _that.getAdjustedExerciseDate())) return false;
if (!Objects.equals(adjustedEarlyTerminationDate, _that.getAdjustedEarlyTerminationDate())) return false;
if (!Objects.equals(meta, _that.getMeta())) return false;
return true;
}
@Override
public int hashCode() {
int _result = 0;
_result = 31 * _result + (adjustedExerciseDate != null ? adjustedExerciseDate.hashCode() : 0);
_result = 31 * _result + (adjustedEarlyTerminationDate != null ? adjustedEarlyTerminationDate.hashCode() : 0);
_result = 31 * _result + (meta != null ? meta.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "CancellationEventBuilder {" +
"adjustedExerciseDate=" + this.adjustedExerciseDate + ", " +
"adjustedEarlyTerminationDate=" + this.adjustedEarlyTerminationDate + ", " +
"meta=" + this.meta +
'}';
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy