Class NutritionLog (0.8.0)

public final class NutritionLog extends GeneratedMessage implements NutritionLogOrBuilder

Holds information about food logged by a user.

There are two ways of creating a nutrition log based on the food type:

  1. Identified food: Using the food field, which is a reference to a Food resource. In this case fields nutrients, energy, energy_from_fat, total_carbohydrate, total_fat, food_display_name will be populated based on the referenced food.
  2. Anonymous food: Using the food_display_name field and setting the nutrients, energy, energy_from_fat, total_carbohydrate, total_fat fields manually.

    The identified food is preferred over the anonymous food. Nutrition logs created from anonymous food are not editable.

Protobuf type google.devicesandservices.health.v4.NutritionLog

Static Fields

ENERGY_FIELD_NUMBER

public static final int ENERGY_FIELD_NUMBER
Field Value
Type Description
int

ENERGY_FROM_FAT_FIELD_NUMBER

public static final int ENERGY_FROM_FAT_FIELD_NUMBER
Field Value
Type Description
int

FOOD_DISPLAY_NAME_FIELD_NUMBER

public static final int FOOD_DISPLAY_NAME_FIELD_NUMBER
Field Value
Type Description
int

FOOD_FIELD_NUMBER

public static final int FOOD_FIELD_NUMBER
Field Value
Type Description
int

INTERVAL_FIELD_NUMBER

public static final int INTERVAL_FIELD_NUMBER
Field Value
Type Description
int

MEAL_TYPE_FIELD_NUMBER

public static final int MEAL_TYPE_FIELD_NUMBER
Field Value
Type Description
int

NUTRIENTS_FIELD_NUMBER

public static final int NUTRIENTS_FIELD_NUMBER
Field Value
Type Description
int

SERVING_FIELD_NUMBER

public static final int SERVING_FIELD_NUMBER
Field Value
Type Description
int

TOTAL_CARBOHYDRATE_FIELD_NUMBER

public static final int TOTAL_CARBOHYDRATE_FIELD_NUMBER
Field Value
Type Description
int

TOTAL_FAT_FIELD_NUMBER

public static final int TOTAL_FAT_FIELD_NUMBER
Field Value
Type Description
int

Static Methods

getDefaultInstance()

public static NutritionLog getDefaultInstance()
Returns
Type Description
NutritionLog

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
Type Description
Descriptor

newBuilder()

public static NutritionLog.Builder newBuilder()
Returns
Type Description
NutritionLog.Builder

newBuilder(NutritionLog prototype)

public static NutritionLog.Builder newBuilder(NutritionLog prototype)
Parameter
Name Description
prototype NutritionLog
Returns
Type Description
NutritionLog.Builder

parseDelimitedFrom(InputStream input)

public static NutritionLog parseDelimitedFrom(InputStream input)
Parameter
Name Description
input InputStream
Returns
Type Description
NutritionLog
Exceptions
Type Description
IOException

parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static NutritionLog parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input InputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
NutritionLog
Exceptions
Type Description
IOException

parseFrom(byte[] data)

public static NutritionLog parseFrom(byte[] data)
Parameter
Name Description
data byte[]
Returns
Type Description
NutritionLog
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public static NutritionLog parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data byte[]
extensionRegistry ExtensionRegistryLite
Returns
Type Description
NutritionLog
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteString data)

public static NutritionLog parseFrom(ByteString data)
Parameter
Name Description
data ByteString
Returns
Type Description
NutritionLog
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public static NutritionLog parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data ByteString
extensionRegistry ExtensionRegistryLite
Returns
Type Description
NutritionLog
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(CodedInputStream input)

public static NutritionLog parseFrom(CodedInputStream input)
Parameter
Name Description
input CodedInputStream
Returns
Type Description
NutritionLog
Exceptions
Type Description
IOException

parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public static NutritionLog parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
NutritionLog
Exceptions
Type Description
IOException

parseFrom(InputStream input)

public static NutritionLog parseFrom(InputStream input)
Parameter
Name Description
input InputStream
Returns
Type Description
NutritionLog
Exceptions
Type Description
IOException

parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static NutritionLog parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input InputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
NutritionLog
Exceptions
Type Description
IOException

parseFrom(ByteBuffer data)

public static NutritionLog parseFrom(ByteBuffer data)
Parameter
Name Description
data ByteBuffer
Returns
Type Description
NutritionLog
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

public static NutritionLog parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data ByteBuffer
extensionRegistry ExtensionRegistryLite
Returns
Type Description
NutritionLog
Exceptions
Type Description
InvalidProtocolBufferException

parser()

public static Parser<NutritionLog> parser()
Returns
Type Description
Parser<NutritionLog>

Methods

equals(Object obj)

public boolean equals(Object obj)
Parameter
Name Description
obj Object
Returns
Type Description
boolean
Overrides

getDefaultInstanceForType()

public NutritionLog getDefaultInstanceForType()
Returns
Type Description
NutritionLog

getEnergy()

public EnergyQuantity getEnergy()

Optional. The total energy of the food, measured in kilocalories (kcal).

.google.devicesandservices.health.v4.EnergyQuantity energy = 4 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
EnergyQuantity

The energy.

getEnergyFromFat()

public EnergyQuantity getEnergyFromFat()

Optional. The energy from fat, measured in kilocalories (kcal).

.google.devicesandservices.health.v4.EnergyQuantity energy_from_fat = 5 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
EnergyQuantity

The energyFromFat.

getEnergyFromFatOrBuilder()

public EnergyQuantityOrBuilder getEnergyFromFatOrBuilder()

Optional. The energy from fat, measured in kilocalories (kcal).

.google.devicesandservices.health.v4.EnergyQuantity energy_from_fat = 5 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
EnergyQuantityOrBuilder

getEnergyOrBuilder()

public EnergyQuantityOrBuilder getEnergyOrBuilder()

Optional. The total energy of the food, measured in kilocalories (kcal).

.google.devicesandservices.health.v4.EnergyQuantity energy = 4 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
EnergyQuantityOrBuilder

getFood()

public String getFood()

Optional. The resource name of the Food item. Required when creating a nutrition log from an identified food. For anonymous food logs, use the food_display_name field instead.

string food = 15 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { ... }

Returns
Type Description
String

The food.

getFoodBytes()

public ByteString getFoodBytes()

Optional. The resource name of the Food item. Required when creating a nutrition log from an identified food. For anonymous food logs, use the food_display_name field instead.

string food = 15 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { ... }

Returns
Type Description
ByteString

The bytes for food.

getFoodDisplayName()

public String getFoodDisplayName()

The display name of the food. For identified food logs, this is populated automatically from the referenced food.

string food_display_name = 16;

Returns
Type Description
String

The foodDisplayName.

getFoodDisplayNameBytes()

public ByteString getFoodDisplayNameBytes()

The display name of the food. For identified food logs, this is populated automatically from the referenced food.

string food_display_name = 16;

Returns
Type Description
ByteString

The bytes for foodDisplayName.

getInterval()

public SessionTimeInterval getInterval()

Required. The time window when the food was logged.

.google.devicesandservices.health.v4.SessionTimeInterval interval = 2 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
SessionTimeInterval

The interval.

getIntervalOrBuilder()

public SessionTimeIntervalOrBuilder getIntervalOrBuilder()

Required. The time window when the food was logged.

.google.devicesandservices.health.v4.SessionTimeInterval interval = 2 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
SessionTimeIntervalOrBuilder

getMealType()

public MealType getMealType()

Optional. The meal category. One of BREAKFAST, LUNCH, DINNER, or SNACK.

.google.devicesandservices.health.v4.MealType meal_type = 13 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
MealType

The mealType.

getMealTypeValue()

public int getMealTypeValue()

Optional. The meal category. One of BREAKFAST, LUNCH, DINNER, or SNACK.

.google.devicesandservices.health.v4.MealType meal_type = 13 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
int

The enum numeric value on the wire for mealType.

getNutrients(int index)

public NutrientQuantity getNutrients(int index)

Optional. An array of individual nutrient values for the nutrition log.

repeated .google.devicesandservices.health.v4.NutrientQuantity nutrients = 3 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
index int
Returns
Type Description
NutrientQuantity

getNutrientsCount()

public int getNutrientsCount()

Optional. An array of individual nutrient values for the nutrition log.

repeated .google.devicesandservices.health.v4.NutrientQuantity nutrients = 3 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
int

getNutrientsList()

public List<NutrientQuantity> getNutrientsList()

Optional. An array of individual nutrient values for the nutrition log.

repeated .google.devicesandservices.health.v4.NutrientQuantity nutrients = 3 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
List<NutrientQuantity>

getNutrientsOrBuilder(int index)

public NutrientQuantityOrBuilder getNutrientsOrBuilder(int index)

Optional. An array of individual nutrient values for the nutrition log.

repeated .google.devicesandservices.health.v4.NutrientQuantity nutrients = 3 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
index int
Returns
Type Description
NutrientQuantityOrBuilder

getNutrientsOrBuilderList()

public List<? extends NutrientQuantityOrBuilder> getNutrientsOrBuilderList()

Optional. An array of individual nutrient values for the nutrition log.

repeated .google.devicesandservices.health.v4.NutrientQuantity nutrients = 3 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
List<? extends com.google.devicesandservices.health.v4.NutrientQuantityOrBuilder>

getParserForType()

public Parser<NutritionLog> getParserForType()
Returns
Type Description
Parser<NutritionLog>
Overrides

getSerializedSize()

public int getSerializedSize()
Returns
Type Description
int
Overrides

getServing()

public NutritionLog.Serving getServing()

Optional. The serving information for the logged food.

.google.devicesandservices.health.v4.NutritionLog.Serving serving = 14 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
NutritionLog.Serving

The serving.

getServingOrBuilder()

public NutritionLog.ServingOrBuilder getServingOrBuilder()

Optional. The serving information for the logged food.

.google.devicesandservices.health.v4.NutritionLog.Serving serving = 14 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
NutritionLog.ServingOrBuilder

getTotalCarbohydrate()

public WeightQuantity getTotalCarbohydrate()

Optional. The total carbohydrate content, measured in grams.

.google.devicesandservices.health.v4.WeightQuantity total_carbohydrate = 7 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
WeightQuantity

The totalCarbohydrate.

getTotalCarbohydrateOrBuilder()

public WeightQuantityOrBuilder getTotalCarbohydrateOrBuilder()

Optional. The total carbohydrate content, measured in grams.

.google.devicesandservices.health.v4.WeightQuantity total_carbohydrate = 7 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
WeightQuantityOrBuilder

getTotalFat()

public WeightQuantity getTotalFat()

Optional. The total fat content, measured in grams.

.google.devicesandservices.health.v4.WeightQuantity total_fat = 8 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
WeightQuantity

The totalFat.

getTotalFatOrBuilder()

public WeightQuantityOrBuilder getTotalFatOrBuilder()

Optional. The total fat content, measured in grams.

.google.devicesandservices.health.v4.WeightQuantity total_fat = 8 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
WeightQuantityOrBuilder

hasEnergy()

public boolean hasEnergy()

Optional. The total energy of the food, measured in kilocalories (kcal).

.google.devicesandservices.health.v4.EnergyQuantity energy = 4 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
boolean

Whether the energy field is set.

hasEnergyFromFat()

public boolean hasEnergyFromFat()

Optional. The energy from fat, measured in kilocalories (kcal).

.google.devicesandservices.health.v4.EnergyQuantity energy_from_fat = 5 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
boolean

Whether the energyFromFat field is set.

hasInterval()

public boolean hasInterval()

Required. The time window when the food was logged.

.google.devicesandservices.health.v4.SessionTimeInterval interval = 2 [(.google.api.field_behavior) = REQUIRED];

Returns
Type Description
boolean

Whether the interval field is set.

hasServing()

public boolean hasServing()

Optional. The serving information for the logged food.

.google.devicesandservices.health.v4.NutritionLog.Serving serving = 14 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
boolean

Whether the serving field is set.

hasTotalCarbohydrate()

public boolean hasTotalCarbohydrate()

Optional. The total carbohydrate content, measured in grams.

.google.devicesandservices.health.v4.WeightQuantity total_carbohydrate = 7 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
boolean

Whether the totalCarbohydrate field is set.

hasTotalFat()

public boolean hasTotalFat()

Optional. The total fat content, measured in grams.

.google.devicesandservices.health.v4.WeightQuantity total_fat = 8 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
boolean

Whether the totalFat field is set.

hashCode()

public int hashCode()
Returns
Type Description
int
Overrides

internalGetFieldAccessorTable()

protected GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable()
Returns
Type Description
FieldAccessorTable
Overrides

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

newBuilderForType()

public NutritionLog.Builder newBuilderForType()
Returns
Type Description
NutritionLog.Builder

newBuilderForType(AbstractMessage.BuilderParent parent)

protected NutritionLog.Builder newBuilderForType(AbstractMessage.BuilderParent parent)
Parameter
Name Description
parent BuilderParent
Returns
Type Description
NutritionLog.Builder
Overrides

toBuilder()

public NutritionLog.Builder toBuilder()
Returns
Type Description
NutritionLog.Builder

writeTo(CodedOutputStream output)

public void writeTo(CodedOutputStream output)
Parameter
Name Description
output CodedOutputStream
Overrides
Exceptions
Type Description
IOException