com.epam.deltix.timebase.messages.schema.SchemaFieldChangeAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of timebase-messages Show documentation
Show all versions of timebase-messages Show documentation
Timebase Common utilities and collections
/*
* Copyright 2021 EPAM Systems, Inc
*
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. 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
*
* 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. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.epam.deltix.timebase.messages.schema;
import com.epam.deltix.timebase.messages.RecordInfo;
import com.epam.deltix.timebase.messages.RecordInterface;
import com.epam.deltix.timebase.messages.SchemaDataType;
import com.epam.deltix.timebase.messages.SchemaElement;
import com.epam.deltix.timebase.messages.SchemaType;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
/**
* Class which defines a change to schema field.
*/
@SchemaElement(
name = "com.epam.deltix.timebase.messages.schema.SchemaFieldChangeAction",
title = "SchemaFieldChangeAction"
)
public class SchemaFieldChangeAction implements SchemaFieldChangeActionInterface {
public static final String CLASS_NAME = SchemaFieldChangeAction.class.getName();
/**
* Previous data field state.
*/
protected DataFieldInfo previousState = null;
/**
* New descriptor state.
*/
protected DataFieldInfo newState = null;
/**
* Bitmask that defines the changes that were applied to the field.
*/
protected SchemaFieldChangeType changeTypes = null;
/**
* Defines the data transformation that was applied to the field.
*/
protected SchemaFieldDataTransformationInfo dataTransformation = null;
/**
* Previous data field state.
* @return Previous State
*/
@SchemaElement
@SchemaType(
isNullable = true,
dataType = SchemaDataType.OBJECT,
nestedTypes = {
StaticDataField.class, NonStaticDataField.class}
)
public DataFieldInfo getPreviousState() {
return previousState;
}
/**
* Previous data field state.
* @param value - Previous State
*/
public void setPreviousState(DataFieldInfo value) {
this.previousState = value;
}
/**
* Previous data field state.
* @return true if Previous State is not null
*/
public boolean hasPreviousState() {
return previousState != null;
}
/**
* Previous data field state.
*/
public void nullifyPreviousState() {
this.previousState = null;
}
/**
* New descriptor state.
* @return New State
*/
@SchemaElement
@SchemaType(
isNullable = true,
dataType = SchemaDataType.OBJECT,
nestedTypes = {
StaticDataField.class, NonStaticDataField.class}
)
public DataFieldInfo getNewState() {
return newState;
}
/**
* New descriptor state.
* @param value - New State
*/
public void setNewState(DataFieldInfo value) {
this.newState = value;
}
/**
* New descriptor state.
* @return true if New State is not null
*/
public boolean hasNewState() {
return newState != null;
}
/**
* New descriptor state.
*/
public void nullifyNewState() {
this.newState = null;
}
/**
* Bitmask that defines the changes that were applied to the field.
* @return Change Types
*/
@SchemaElement
@SchemaType(
isNullable = false
)
public SchemaFieldChangeType getChangeTypes() {
return changeTypes;
}
/**
* Bitmask that defines the changes that were applied to the field.
* @param value - Change Types
*/
public void setChangeTypes(SchemaFieldChangeType value) {
this.changeTypes = value;
}
/**
* Bitmask that defines the changes that were applied to the field.
* @return true if Change Types is not null
*/
public boolean hasChangeTypes() {
return changeTypes != null;
}
/**
* Bitmask that defines the changes that were applied to the field.
*/
public void nullifyChangeTypes() {
this.changeTypes = null;
}
/**
* Defines the data transformation that was applied to the field.
* @return Data Transformation
*/
@SchemaElement
@SchemaType(
isNullable = true,
dataType = SchemaDataType.OBJECT,
nestedTypes = {
SchemaFieldDataTransformation.class}
)
public SchemaFieldDataTransformationInfo getDataTransformation() {
return dataTransformation;
}
/**
* Defines the data transformation that was applied to the field.
* @param value - Data Transformation
*/
public void setDataTransformation(SchemaFieldDataTransformationInfo value) {
this.dataTransformation = value;
}
/**
* Defines the data transformation that was applied to the field.
* @return true if Data Transformation is not null
*/
public boolean hasDataTransformation() {
return dataTransformation != null;
}
/**
* Defines the data transformation that was applied to the field.
*/
public void nullifyDataTransformation() {
this.dataTransformation = null;
}
/**
* Creates new instance of this class.
* @return new instance of this class.
*/
protected SchemaFieldChangeAction createInstance() {
return new SchemaFieldChangeAction();
}
/**
* Method nullifies all instance properties
*/
public SchemaFieldChangeAction nullify() {
nullifyPreviousState();
nullifyNewState();
nullifyChangeTypes();
nullifyDataTransformation();
return this;
}
/**
* Resets all instance properties to their default values
*/
public SchemaFieldChangeAction reset() {
previousState = null;
newState = null;
changeTypes = null;
dataTransformation = null;
return this;
}
/**
* Method copies state to a given instance
*/
public SchemaFieldChangeAction clone() {
SchemaFieldChangeAction t = createInstance();
t.copyFrom(this);
return t;
}
/**
* Indicates whether some other object is "equal to" this one.
*/
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof SchemaFieldChangeActionInfo)) return false;
SchemaFieldChangeActionInfo other =(SchemaFieldChangeActionInfo)obj;
if (hasPreviousState() != other.hasPreviousState()) return false;
if (hasPreviousState() && !(getPreviousState().equals(other.getPreviousState()))) return false;
if (hasNewState() != other.hasNewState()) return false;
if (hasNewState() && !(getNewState().equals(other.getNewState()))) return false;
if (hasChangeTypes() != other.hasChangeTypes()) return false;
if (hasChangeTypes() && getChangeTypes() != other.getChangeTypes()) return false;
if (hasDataTransformation() != other.hasDataTransformation()) return false;
if (hasDataTransformation() && !(getDataTransformation().equals(other.getDataTransformation()))) return false;
return true;
}
/**
* Returns a hash code value for the object. This method is * supported for the benefit of hash tables such as those provided by.
*/
@Override
public int hashCode() {
int hash = 0;
if (hasPreviousState()) {
hash = hash * 31 + getPreviousState().hashCode();
}
if (hasNewState()) {
hash = hash * 31 + getNewState().hashCode();
}
if (hasChangeTypes()) {
hash = hash * 31 + getChangeTypes().getNumber();
}
if (hasDataTransformation()) {
hash = hash * 31 + getDataTransformation().hashCode();
}
return hash;
}
/**
* Method copies state to a given instance
* @param template class instance that should be used as a copy source
*/
public SchemaFieldChangeAction copyFrom(RecordInfo template) {
if (template instanceof SchemaFieldChangeActionInfo) {
SchemaFieldChangeActionInfo t = (SchemaFieldChangeActionInfo)template;
if (t.hasPreviousState()) {
if (hasPreviousState() && getPreviousState() instanceof RecordInterface) {
((RecordInterface)getPreviousState()).copyFrom(t.getPreviousState());
} else {
setPreviousState((DataFieldInfo)t.getPreviousState().clone());
}
} else {
nullifyPreviousState();
}
if (t.hasNewState()) {
if (hasNewState() && getNewState() instanceof RecordInterface) {
((RecordInterface)getNewState()).copyFrom(t.getNewState());
} else {
setNewState((DataFieldInfo)t.getNewState().clone());
}
} else {
nullifyNewState();
}
if (t.hasChangeTypes()) {
setChangeTypes(t.getChangeTypes());
} else {
nullifyChangeTypes();
}
if (t.hasDataTransformation()) {
if (hasDataTransformation() && getDataTransformation() instanceof RecordInterface) {
((RecordInterface)getDataTransformation()).copyFrom(t.getDataTransformation());
} else {
setDataTransformation((SchemaFieldDataTransformationInfo)t.getDataTransformation().clone());
}
} else {
nullifyDataTransformation();
}
}
return this;
}
/**
* @return a string representation of this class object.
*/
@Override
public String toString() {
StringBuilder str = new StringBuilder();
return toString(str).toString();
}
/**
* @return a string representation of this class object.
*/
@Override
public StringBuilder toString(StringBuilder str) {
str.append("{ \"$type\": \"SchemaFieldChangeAction\"");
if (hasPreviousState()) {
str.append(", \"previousState\": ");
getPreviousState().toString(str);
}
if (hasNewState()) {
str.append(", \"newState\": ");
getNewState().toString(str);
}
if (hasChangeTypes()) {
str.append(", \"changeTypes\": \"").append(getChangeTypes()).append("\"");
}
if (hasDataTransformation()) {
str.append(", \"dataTransformation\": ");
getDataTransformation().toString(str);
}
str.append("}");
return str;
}
}