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

org.openlca.proto.io.input.FlowPropertyReader Maven / Gradle / Ivy


package org.openlca.proto.io.input;

import org.openlca.core.io.EntityResolver;
import org.openlca.core.model.FlowProperty;
import org.openlca.core.model.FlowPropertyType;
import org.openlca.proto.ProtoFlowProperty;
import org.openlca.proto.ProtoFlowPropertyType;

public record FlowPropertyReader(EntityResolver resolver)
	implements EntityReader {

	@Override
	public FlowProperty read(ProtoFlowProperty proto) {
		var property = new FlowProperty();
		update(property, proto);
		return property;
	}

	@Override
	public void update(FlowProperty property, ProtoFlowProperty proto) {
		Util.mapBase(property, ProtoBox.of(proto), resolver);
		property.flowPropertyType =
			proto.getFlowPropertyType() == ProtoFlowPropertyType.ECONOMIC_QUANTITY
				? FlowPropertyType.ECONOMIC
				: FlowPropertyType.PHYSICAL;
		property.unitGroup = Util.getUnitGroup(resolver, proto.getUnitGroup());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy