func NewCommodityDTOBuilder(commodityType proto.CommodityDTO_CommodityType) *CommodityDTOBuilder { commodityDTO := new(proto.CommodityDTO) commodityDTO.CommodityType = &commodityType return &CommodityDTOBuilder{ commDTO: commodityDTO, } }
// Add an commodity which buys from the current provider. func (eb *EntityDTOBuilder) Buys(commodityType proto.CommodityDTO_CommodityType, key string, used float64) *EntityDTOBuilder { if eb.currentProvider == nil { // TODO should have error message. Notify set current provider first eb.err = fmt.Errorf("Provider has not been set for %v", commodityType) return eb } commDTO := new(proto.CommodityDTO) commDTO.CommodityType = &commodityType commDTO.Key = &key commDTO.Used = &used eb.BuysCommodity(commDTO) return eb }
func (eb *EntityDTOBuilder) Sells(commodityType proto.CommodityDTO_CommodityType, key string) *EntityDTOBuilder { if eb.err != nil { return eb } commDTO := new(proto.CommodityDTO) commDTO.CommodityType = &commodityType commDTO.Key = &key commSold := eb.entity.CommoditiesSold commSold = append(commSold, commDTO) eb.entity.CommoditiesSold = commSold eb.commodity = commDTO return eb }