/** * Sets the price of the item. * * @param value * @param currency */ public void setPrice(float value, String currency) { setPrice(new NumberUnit<Float>(value, currency)); }
private static Shipping extractShippingFromElements(GoogleBaseAttribute attribute) { String country = attribute.getSubElementValue(ShippingField.Country.getElemName()); Collection<String> regions = attribute.getSubElementValues(ShippingField.Region.getElemName()); String price = attribute.getSubElementValue(ShippingField.Price.getElemName()); String service = attribute.getSubElementValue(ShippingField.Service.getElemName()); if (price == null) { throw new NumberFormatException( "missing 'price' element in shipping attribute: " + attribute); } NumberUnit<Float> priceUnit; try { priceUnit = toFloatUnit(price); } catch (NumberFormatException e) { priceUnit = new NumberUnit<Float>(Float.parseFloat(price), null); } return new Shipping(country, regions, service, priceUnit.getValue(), priceUnit.getUnit()); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#NUMBER_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value attribute value * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addNumberUnitAttribute(String name, NumberUnit<Number> value) { return addAttribute(new GoogleBaseAttribute(name, GoogleBaseAttributeType.NUMBER_UNIT, value.toString())); }
priceUnit = toFloatUnit(price); } catch (NumberFormatException e) { priceUnit = new NumberUnit<Float>(Float.parseFloat(price), null); "missing 'price' element in shipping attribute: " + attribute); return new Shipping(country, regions, service, priceUnit.getValue(), priceUnit.getUnit());
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#FLOAT_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value attribute value * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addFloatUnitAttribute(String name, NumberUnit<Float> value) { return addAttribute(new GoogleBaseAttribute(name, GoogleBaseAttributeType.FLOAT_UNIT, value.toString())); }
priceUnit = toFloatUnit(price); } catch (NumberFormatException e) { priceUnit = new NumberUnit<Float>(Float.parseFloat(price), null); "missing 'price' element in shipping attribute: " + attribute); return new Shipping(country, regions, service, priceUnit.getValue(), priceUnit.getUnit());
/** Sets delivery radius. */ public void setDeliveryRadius(float value, String unit) { setDeliveryRadius(new NumberUnit<Float>(value, unit)); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#INT_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value attribute value * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addIntUnitAttribute(String name, NumberUnit<Integer> value) { return addAttribute(new GoogleBaseAttribute(name, GoogleBaseAttributeType.INT_UNIT, value.toString())); }
private static Shipping extractShippingFromElements(GoogleBaseAttribute attribute) { String country = attribute.getSubElementValue(ShippingField.Country.getElemName()); Collection<String> regions = attribute.getSubElementValues(ShippingField.Region.getElemName()); String price = attribute.getSubElementValue(ShippingField.Price.getElemName()); String service = attribute.getSubElementValue(ShippingField.Service.getElemName()); if (price == null) { throw new NumberFormatException( "missing 'price' element in shipping attribute: " + attribute); } NumberUnit<Float> priceUnit; try { priceUnit = toFloatUnit(price); } catch (NumberFormatException e) { priceUnit = new NumberUnit<Float>(Float.parseFloat(price), null); } return new Shipping(country, regions, service, priceUnit.getValue(), priceUnit.getUnit()); }
/** * Sets the price of the item. * * @param value * @param currency */ public void setPrice(float value, String currency) { setPrice(new NumberUnit<Float>(value, currency)); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#FLOAT_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value attribute value * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addFloatUnitAttribute(String name, NumberUnit<Float> value) { return addAttribute(new GoogleBaseAttribute(name, GoogleBaseAttributeType.FLOAT_UNIT, value.toString())); }
/** Sets delivery radius. */ public void setDeliveryRadius(float value, String unit) { setDeliveryRadius(new NumberUnit<Float>(value, unit)); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#INT_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value attribute value * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addIntUnitAttribute(String name, NumberUnit<Integer> value) { return addAttribute(new GoogleBaseAttribute(name, GoogleBaseAttributeType.INT_UNIT, value.toString())); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#INT_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value * @param unit * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addIntUnitAttribute(String name, int value, String unit) { return addIntUnitAttribute(name, new NumberUnit<Integer>(value, unit)); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#NUMBER_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value attribute value * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addNumberUnitAttribute(String name, NumberUnit<Number> value) { return addAttribute(new GoogleBaseAttribute(name, GoogleBaseAttributeType.NUMBER_UNIT, value.toString())); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#NUMBER_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value * @param unit * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addNumberUnitAttribute(String name, Number value, String unit) { return addNumberUnitAttribute(name, new NumberUnit<Number>(value, unit)); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#NUMBER_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value * @param unit * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addNumberUnitAttribute(String name, Number value, String unit) { return addNumberUnitAttribute(name, new NumberUnit<Number>(value, unit)); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#FLOAT_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value * @param unit * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addFloatUnitAttribute(String name, float value, String unit) { return addFloatUnitAttribute(name, new NumberUnit<Float>(value, unit)); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#INT_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value * @param unit * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addIntUnitAttribute(String name, int value, String unit) { return addIntUnitAttribute(name, new NumberUnit<Integer>(value, unit)); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#FLOAT_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value * @param unit * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addFloatUnitAttribute(String name, float value, String unit) { return addFloatUnitAttribute(name, new NumberUnit<Float>(value, unit)); }