All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.rosetta.testconditional.model.X25 Maven / Gradle / Ivy

There is a newer version: 11.25.1
Show newest version
package com.rosetta.testconditional.model;

import com.google.common.collect.ImmutableList;
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.testconditional.model.X25;
import com.rosetta.testconditional.model.X25.X25Builder;
import com.rosetta.testconditional.model.X25.X25BuilderImpl;
import com.rosetta.testconditional.model.X25.X25Impl;
import com.rosetta.testconditional.model.meta.X25Meta;
import com.rosetta.util.ListEquals;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import static java.util.Optional.ofNullable;

/**
 * @version test
 */
@RosettaDataType(value="X25", builder=X25.X25BuilderImpl.class, version="test")
public interface X25 extends RosettaModelObject {

	X25Meta metaData = new X25Meta();

	/*********************** Getter Methods  ***********************/
	List getAField();

	/*********************** Build Methods  ***********************/
	X25 build();
	
	X25.X25Builder toBuilder();
	
	static X25.X25Builder builder() {
		return new X25.X25BuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return X25.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processor.processBasic(path.newSubPath("aField"), String.class, getAField(), this);
	}
	

	/*********************** Builder Interface  ***********************/
	interface X25Builder extends X25, RosettaModelObjectBuilder {
		X25.X25Builder addAField(String aField0);
		X25.X25Builder addAField(String aField1, int _idx);
		X25.X25Builder addAField(List aField2);
		X25.X25Builder setAField(List aField3);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processor.processBasic(path.newSubPath("aField"), String.class, getAField(), this);
		}
		

		X25.X25Builder prune();
	}

	/*********************** Immutable Implementation of X25  ***********************/
	class X25Impl implements X25 {
		private final List aField;
		
		protected X25Impl(X25.X25Builder builder) {
			this.aField = ofNullable(builder.getAField()).filter(_l->!_l.isEmpty()).map(ImmutableList::copyOf).orElse(null);
		}
		
		@Override
		@RosettaAttribute("aField")
		public List getAField() {
			return aField;
		}
		
		@Override
		public X25 build() {
			return this;
		}
		
		@Override
		public X25.X25Builder toBuilder() {
			X25.X25Builder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(X25.X25Builder builder) {
			ofNullable(getAField()).ifPresent(builder::setAField);
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
		
			X25 _that = getType().cast(o);
		
			if (!ListEquals.listEquals(aField, _that.getAField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (aField != null ? aField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "X25 {" +
				"aField=" + this.aField +
			'}';
		}
	}

	/*********************** Builder Implementation of X25  ***********************/
	class X25BuilderImpl implements X25.X25Builder {
	
		protected List aField = new ArrayList<>();
	
		public X25BuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("aField")
		public List getAField() {
			return aField;
		}
		
		@Override
		public X25.X25Builder addAField(String aField) {
			if (aField!=null) this.aField.add(aField);
			return this;
		}
		
		@Override
		public X25.X25Builder addAField(String aField, int _idx) {
			getIndex(this.aField, _idx, () -> aField);
			return this;
		}
		@Override 
		public X25.X25Builder addAField(List aFields) {
			if (aFields != null) {
				for (String toAdd : aFields) {
					this.aField.add(toAdd);
				}
			}
			return this;
		}
		
		@Override 
		@RosettaAttribute("aField")
		public X25.X25Builder setAField(List aFields) {
			if (aFields == null)  {
				this.aField = new ArrayList<>();
			}
			else {
				this.aField = aFields.stream()
					.collect(Collectors.toCollection(()->new ArrayList<>()));
			}
			return this;
		}
		
		
		@Override
		public X25 build() {
			return new X25.X25Impl(this);
		}
		
		@Override
		public X25.X25Builder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public X25.X25Builder prune() {
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getAField()!=null && !getAField().isEmpty()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public X25.X25Builder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			X25.X25Builder o = (X25.X25Builder) other;
			
			
			merger.mergeBasic(getAField(), o.getAField(), (Consumer) this::addAField);
			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;
		
			X25 _that = getType().cast(o);
		
			if (!ListEquals.listEquals(aField, _that.getAField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (aField != null ? aField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "X25Builder {" +
				"aField=" + this.aField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy