Class Nutrient

java.lang.Object
com.codename1.health.nutrition.Nutrient

public final class Nutrient extends Object

A single nutrient that a NutritionSample can carry -- a macronutrient, a vitamin, a mineral.

Interned constants, like HealthDataType, so == is a valid identity test and forId(String) stays total across framework versions.

Each nutrient declares the unit its amounts are expressed in. That is not cosmetic: sodium is conventionally logged in milligrams and protein in grams, and a food database that mixes them up is off by a thousand.

  • Field Details

    • ENERGY

      public static final Nutrient ENERGY
      Food energy. Note that this is also available as a standalone type, HealthDataType.DIETARY_ENERGY; writing a NutritionSample that carries it makes it part of a logged meal rather than a bare total.
    • PROTEIN

      public static final Nutrient PROTEIN
    • TOTAL_FAT

      public static final Nutrient TOTAL_FAT
    • SATURATED_FAT

      public static final Nutrient SATURATED_FAT
    • MONOUNSATURATED_FAT

      public static final Nutrient MONOUNSATURATED_FAT
    • POLYUNSATURATED_FAT

      public static final Nutrient POLYUNSATURATED_FAT
    • TRANS_FAT

      public static final Nutrient TRANS_FAT
    • CHOLESTEROL

      public static final Nutrient CHOLESTEROL
    • TOTAL_CARBOHYDRATE

      public static final Nutrient TOTAL_CARBOHYDRATE
    • DIETARY_FIBER

      public static final Nutrient DIETARY_FIBER
    • SUGAR

      public static final Nutrient SUGAR
    • WATER

      public static final Nutrient WATER
    • SODIUM

      public static final Nutrient SODIUM
    • POTASSIUM

      public static final Nutrient POTASSIUM
    • CALCIUM

      public static final Nutrient CALCIUM
    • IRON

      public static final Nutrient IRON
    • MAGNESIUM

      public static final Nutrient MAGNESIUM
    • ZINC

      public static final Nutrient ZINC
    • PHOSPHORUS

      public static final Nutrient PHOSPHORUS
    • IODINE

      public static final Nutrient IODINE
    • SELENIUM

      public static final Nutrient SELENIUM
    • COPPER

      public static final Nutrient COPPER
    • MANGANESE

      public static final Nutrient MANGANESE
    • CHROMIUM

      public static final Nutrient CHROMIUM
    • MOLYBDENUM

      public static final Nutrient MOLYBDENUM
    • CHLORIDE

      public static final Nutrient CHLORIDE
    • VITAMIN_A

      public static final Nutrient VITAMIN_A
    • THIAMIN

      public static final Nutrient THIAMIN
    • RIBOFLAVIN

      public static final Nutrient RIBOFLAVIN
    • NIACIN

      public static final Nutrient NIACIN
    • PANTOTHENIC_ACID

      public static final Nutrient PANTOTHENIC_ACID
    • VITAMIN_B6

      public static final Nutrient VITAMIN_B6
    • BIOTIN

      public static final Nutrient BIOTIN
    • VITAMIN_B12

      public static final Nutrient VITAMIN_B12
    • VITAMIN_C

      public static final Nutrient VITAMIN_C
    • VITAMIN_D

      public static final Nutrient VITAMIN_D
    • VITAMIN_E

      public static final Nutrient VITAMIN_E
    • VITAMIN_K

      public static final Nutrient VITAMIN_K
    • FOLATE

      public static final Nutrient FOLATE
    • CAFFEINE

      public static final Nutrient CAFFEINE
  • Method Details

    • getId

      public String getId()
      The stable, portable identifier for this nutrient.
    • getUnit

      public HealthUnit getUnit()
      The unit amounts of this nutrient are expressed in.
    • forId

      public static Nutrient forId(String id)
      Looks a nutrient up by getId(), or null when unknown to this version of the framework.
    • values

      public static List<Nutrient> values()
      Every nutrient this framework understands.
    • toString

      public String toString()
      Description copied from class: Object
      Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
      Overrides:
      toString in class Object