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

com.logicommerce.sdktest.definition.ConfigDefinitionFakeBuilder Maven / Gradle / Ivy

There is a newer version: 2.1.2
Show newest version
package com.logicommerce.sdktest.definition;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import com.logicommerce.sdk.definition.implementations.MappedFieldDefinitionImpl;

public abstract class ConfigDefinitionFakeBuilder> {

	private List> properties;

	private boolean hasAdditionalProperties;

	private List> additionalProperties;

	private List> mappedFields;


	protected ConfigDefinitionFakeBuilder() {
		properties = new ArrayList<>();
		additionalProperties = new ArrayList<>();
		mappedFields = new ArrayList<>();
	}

	public PropertyDefinitionFakeBuilder property() {
		PropertyDefinitionFakeBuilder property = new PropertyDefinitionFakeBuilder<>(returnThis());
		properties.add(property);
		return property;
	}

	public T hasAdditionalProperties(boolean hasAdditionalProperties) {
		this.hasAdditionalProperties = hasAdditionalProperties;
		return returnThis();
	}

	public PropertyDefinitionFakeBuilder additionalProperty() {
		PropertyDefinitionFakeBuilder additionalProperty = new PropertyDefinitionFakeBuilder<>(returnThis());
		properties.add(additionalProperty);
		return additionalProperty;
	}

	public MappedFieldDefinitionImpl.Builder mappedField() {
		MappedFieldDefinitionImpl.Builder mappedField = new MappedFieldDefinitionImpl.Builder<>(returnThis());
		mappedFields.add(mappedField);
		return mappedField;
	}

	public void setAttributes(ConfigDefinitionFake configDefinition) {
		configDefinition
			.setProperties(properties.stream().map(PropertyDefinitionFakeBuilder::build).collect(Collectors.toList()));
		configDefinition.setHasAdditionalProperties(hasAdditionalProperties);
		configDefinition.setAdditionalProperties(
			additionalProperties.stream().map(PropertyDefinitionFakeBuilder::build).collect(Collectors.toList()));
		configDefinition.setMappedFields(
			mappedFields.stream().map(MappedFieldDefinitionImpl.Builder::build).collect(Collectors.toList()));
	}

	protected abstract T returnThis();

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy