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

com.rosetta.mappingprocessortest.model.Leg Maven / Gradle / Ivy

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

import com.rosetta.mappingprocessortest.model.Leg;
import com.rosetta.mappingprocessortest.model.Leg.LegBuilder;
import com.rosetta.mappingprocessortest.model.Leg.LegBuilderImpl;
import com.rosetta.mappingprocessortest.model.Leg.LegImpl;
import com.rosetta.mappingprocessortest.model.meta.LegMeta;
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="Leg", builder=Leg.LegBuilderImpl.class, version="test")
public interface Leg extends RosettaModelObject {

	LegMeta metaData = new LegMeta();

	/*********************** Getter Methods  ***********************/
	String getA();
	String getB();

	/*********************** Build Methods  ***********************/
	Leg build();
	
	Leg.LegBuilder toBuilder();
	
	static Leg.LegBuilder builder() {
		return new Leg.LegBuilderImpl();
	}

	/*********************** Utility Methods  ***********************/
	@Override
	default RosettaMetaData metaData() {
		return metaData;
	}
	
	@Override
	default Class getType() {
		return Leg.class;
	}
	
	
	@Override
	default void process(RosettaPath path, Processor processor) {
		processor.processBasic(path.newSubPath("a"), String.class, getA(), this);
		processor.processBasic(path.newSubPath("b"), String.class, getB(), this);
	}
	

	/*********************** Builder Interface  ***********************/
	interface LegBuilder extends Leg, RosettaModelObjectBuilder {
		Leg.LegBuilder setA(String a);
		Leg.LegBuilder setB(String b);

		@Override
		default void process(RosettaPath path, BuilderProcessor processor) {
			processor.processBasic(path.newSubPath("a"), String.class, getA(), this);
			processor.processBasic(path.newSubPath("b"), String.class, getB(), this);
		}
		

		Leg.LegBuilder prune();
	}

	/*********************** Immutable Implementation of Leg  ***********************/
	class LegImpl implements Leg {
		private final String a;
		private final String b;
		
		protected LegImpl(Leg.LegBuilder builder) {
			this.a = builder.getA();
			this.b = builder.getB();
		}
		
		@Override
		@RosettaAttribute("a")
		public String getA() {
			return a;
		}
		
		@Override
		@RosettaAttribute("b")
		public String getB() {
			return b;
		}
		
		@Override
		public Leg build() {
			return this;
		}
		
		@Override
		public Leg.LegBuilder toBuilder() {
			Leg.LegBuilder builder = builder();
			setBuilderFields(builder);
			return builder;
		}
		
		protected void setBuilderFields(Leg.LegBuilder builder) {
			ofNullable(getA()).ifPresent(builder::setA);
			ofNullable(getB()).ifPresent(builder::setB);
		}

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

	/*********************** Builder Implementation of Leg  ***********************/
	class LegBuilderImpl implements Leg.LegBuilder {
	
		protected String a;
		protected String b;
	
		public LegBuilderImpl() {
		}
	
		@Override
		@RosettaAttribute("a")
		public String getA() {
			return a;
		}
		
		@Override
		@RosettaAttribute("b")
		public String getB() {
			return b;
		}
		
		@Override
		@RosettaAttribute("a")
		public Leg.LegBuilder setA(String a) {
			this.a = a==null?null:a;
			return this;
		}
		@Override
		@RosettaAttribute("b")
		public Leg.LegBuilder setB(String b) {
			this.b = b==null?null:b;
			return this;
		}
		
		@Override
		public Leg build() {
			return new Leg.LegImpl(this);
		}
		
		@Override
		public Leg.LegBuilder toBuilder() {
			return this;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Leg.LegBuilder prune() {
			return this;
		}
		
		@Override
		public boolean hasData() {
			if (getA()!=null) return true;
			if (getB()!=null) return true;
			return false;
		}
	
		@SuppressWarnings("unchecked")
		@Override
		public Leg.LegBuilder merge(RosettaModelObjectBuilder other, BuilderMerger merger) {
			Leg.LegBuilder o = (Leg.LegBuilder) other;
			
			
			merger.mergeBasic(getA(), o.getA(), this::setA);
			merger.mergeBasic(getB(), o.getB(), this::setB);
			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;
		
			Leg _that = getType().cast(o);
		
			if (!Objects.equals(a, _that.getA())) return false;
			if (!Objects.equals(b, _that.getB())) return false;
			return true;
		}
		
		@Override
		public int hashCode() {
			int _result = 0;
			_result = 31 * _result + (a != null ? a.hashCode() : 0);
			_result = 31 * _result + (b != null ? b.hashCode() : 0);
			return _result;
		}
		
		@Override
		public String toString() {
			return "LegBuilder {" +
				"a=" + this.a + ", " +
				"b=" + this.b +
			'}';
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy