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

com.rosetta.jsonparsingtestschargor.model.First Maven / Gradle / Ivy

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

import com.rosetta.jsonparsingtestschargor.model.Document;
import com.rosetta.jsonparsingtestschargor.model.First;
import com.rosetta.jsonparsingtestschargor.model.First.FirstBuilder;
import com.rosetta.jsonparsingtestschargor.model.First.FirstBuilderImpl;
import com.rosetta.jsonparsingtestschargor.model.First.FirstImpl;
import com.rosetta.jsonparsingtestschargor.model.TopLaw;
import com.rosetta.jsonparsingtestschargor.model.meta.FirstMeta;
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 java.util.Objects;

import static java.util.Optional.ofNullable;

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

	FirstMeta metaData = new FirstMeta();

	/*********************** Getter Methods  ***********************/
	Document getDocField();
	TopLaw getTopField();

	/*********************** Build Methods  ***********************/
	First build();
	
	First.FirstBuilder toBuilder();
	
	static First.FirstBuilder builder() {
		return new First.FirstBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return First.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processRosetta(path.newSubPath("docField"), processor, Document.class, getDocField());
		processRosetta(path.newSubPath("topField"), processor, TopLaw.class, getTopField());
	}
	

	/*********************** Builder Interface  ***********************/
	interface FirstBuilder extends First, RosettaModelObjectBuilder {
		Document.DocumentBuilder getOrCreateDocField();
		Document.DocumentBuilder getDocField();
		TopLaw.TopLawBuilder getOrCreateTopField();
		TopLaw.TopLawBuilder getTopField();
		First.FirstBuilder setDocField(Document docField);
		First.FirstBuilder setTopField(TopLaw topField);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processRosetta(path.newSubPath("docField"), processor, Document.DocumentBuilder.class, getDocField());
			processRosetta(path.newSubPath("topField"), processor, TopLaw.TopLawBuilder.class, getTopField());
		}
		

		First.FirstBuilder prune();
	}

	/*********************** Immutable Implementation of First  ***********************/
	class FirstImpl implements First {
		private final Document docField;
		private final TopLaw topField;
		
		protected FirstImpl(First.FirstBuilder builder) {
			this.docField = ofNullable(builder.getDocField()).map(f->f.build()).orElse(null);
			this.topField = ofNullable(builder.getTopField()).map(f->f.build()).orElse(null);
		}
		
		@Override
		@RosettaAttribute("docField")
		public Document getDocField() {
			return docField;
		}
		
		@Override
		@RosettaAttribute("topField")
		public TopLaw getTopField() {
			return topField;
		}
		
		@Override
		public First build() {
			return this;
		}
		
		@Override
		public First.FirstBuilder toBuilder() {
			First.FirstBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(First.FirstBuilder builder) {
			ofNullable(getDocField()).ifPresent(builder::setDocField);
			ofNullable(getTopField()).ifPresent(builder::setTopField);
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || !(o instanceof RosettaModelObject) || !getType().equals(((RosettaModelObject)o).getType())) return false;
		
			First _that = getType().cast(o);
		
			if (!Objects.equals(docField, _that.getDocField())) return false;
			if (!Objects.equals(topField, _that.getTopField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (docField != null ? docField.hashCode() : 0);
			_result = 31 * _result + (topField != null ? topField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "First {" +
				"docField=" + this.docField + ", " +
				"topField=" + this.topField +
			'}';
		}
	}

	/*********************** Builder Implementation of First  ***********************/
	class FirstBuilderImpl implements First.FirstBuilder {
	
		protected Document.DocumentBuilder docField;
		protected TopLaw.TopLawBuilder topField;
	
		public FirstBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("docField")
		public Document.DocumentBuilder getDocField() {
			return docField;
		}
		
		@Override
		public Document.DocumentBuilder getOrCreateDocField() {
			Document.DocumentBuilder result;
			if (docField!=null) {
				result = docField;
			}
			else {
				result = docField = Document.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("topField")
		public TopLaw.TopLawBuilder getTopField() {
			return topField;
		}
		
		@Override
		public TopLaw.TopLawBuilder getOrCreateTopField() {
			TopLaw.TopLawBuilder result;
			if (topField!=null) {
				result = topField;
			}
			else {
				result = topField = TopLaw.builder();
			}
			
			return result;
		}
		
		@Override
		@RosettaAttribute("docField")
		public First.FirstBuilder setDocField(Document docField) {
			this.docField = docField==null?null:docField.toBuilder();
			return this;
		}
		@Override
		@RosettaAttribute("topField")
		public First.FirstBuilder setTopField(TopLaw topField) {
			this.topField = topField==null?null:topField.toBuilder();
			return this;
		}
		
		@Override
		public First build() {
			return new First.FirstImpl(this);
		}
		
		@Override
		public First.FirstBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public First.FirstBuilder prune() {
			if (docField!=null && !docField.prune().hasData()) docField = null;
			if (topField!=null && !topField.prune().hasData()) topField = null;
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getDocField()!=null && getDocField().hasData()) return true;
			if (getTopField()!=null && getTopField().hasData()) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public First.FirstBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			First.FirstBuilder o = (First.FirstBuilder) other;
			
			merger.mergeRosetta(getDocField(), o.getDocField(), this::setDocField);
			merger.mergeRosetta(getTopField(), o.getTopField(), this::setTopField);
			
			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;
		
			First _that = getType().cast(o);
		
			if (!Objects.equals(docField, _that.getDocField())) return false;
			if (!Objects.equals(topField, _that.getTopField())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (docField != null ? docField.hashCode() : 0);
			_result = 31 * _result + (topField != null ? topField.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "FirstBuilder {" +
				"docField=" + this.docField + ", " +
				"topField=" + this.topField +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy