Class YAMLFileManager

java.lang.Object
com.shaft.tools.io.YAMLFileManager
Direct Known Subclasses:
SHAFT.TestData.YAML

public class YAMLFileManager extends Object
  • Field Details

  • Constructor Details

    • YAMLFileManager

      public YAMLFileManager(String filePath)
      Creating an instance of YAMLFileManager
      Parameters:
      filePath - target test data yaml file path
  • Method Details

    • get

      public Map<String,Object> get()
      Fetch all the date from the YAML file
      Returns:
      all date existed in the YAML file as Map
    • get

      public Object get(String key)
      Fetch a single piece of data from the YAML file using a single key or a series of keys

      to support key series use a dot to separate keys "key1.key2" to support list in the key series "key[index]"

      Parameters:
      key - the path to the wanted data can be a single key or a series of keys
      Returns:
      the wanted value as Object
    • getTestData

      public String getTestData(String key)
      Fetch a single piece of data from the YAML file using a single key or a series of keys

      to support key series use a dot to separate keys "key1.key2" to support list in the key series "key[index]"

      Parameters:
      key - the path to the wanted data can be a single key or a series of keys
      Returns:
      the wanted value as String even if it not a string it will parse it to be string
    • getString

      public String getString(String key)
      Fetch a single piece of data from the YAML file using a single key or a series of keys

      to support key series use a dot to separate keys "key1.key2" to support list in the key series "key[index]"

      Parameters:
      key - the path to the wanted data can be a single key or a series of keys
      Returns:
      the wanted value as String if the value is not a string it will throw an error
    • getInteger

      public Integer getInteger(String key)
      Fetch a single piece of data from the YAML file using a single key or a series of keys

      to support key series use a dot to separate keys "key1.key2" to support list in the key series "key[index]"

      Parameters:
      key - the path to the wanted data can be a single key or a series of keys
      Returns:
      the wanted value as Integer
    • getDouble

      public Double getDouble(String key)
      Fetch a single piece of data from the YAML file using a single key or a series of keys

      to support key series use a dot to separate keys "key1.key2" to support list in the key series "key[index]"

      Parameters:
      key - the path to the wanted data can be a single key or a series of keys
      Returns:
      the wanted value as Double
    • getLong

      public Long getLong(String key)
      Fetch a single piece of data from the YAML file using a single key or a series of keys

      to support key series use a dot to separate keys "key1.key2" to support list in the key series "key[index]"

      to support Long values the char "L" should be added at the end of the number

      Parameters:
      key - the path to the wanted data can be a single key or a series of keys
      Returns:
      the wanted value as Long
    • getBoolean

      public Boolean getBoolean(String key)
      Fetch a single piece of data from the YAML file using a single key or a series of keys

      to support key series use a dot to separate keys "key1.key2" to support list in the key series "key[index]"

      Parameters:
      key - the path to the wanted data can be a single key or a series of keys
      Returns:
      the wanted value as Boolean
    • getDate

      public Date getDate(String key)
      Fetch a single piece of data from the YAML file using a single key or a series of keys

      to support key series use a dot to separate keys "key1.key2" to support list in the key series "key[index]"

      Always return date on the local time zone

      Parameters:
      key - the path to the wanted data can be a single key or a series of keys
      Returns:
      the wanted value as Date
    • getAs

      public <T> T getAs(String key, Class<T> clazz)
      Fetch a single piece of data from the YAML file using a single key or a series of keys

      to support key series use a dot to separate keys "key1.key2" to support list in the key series "key[index]"

      Parameters:
      key - the path to the wanted data can be a single key or a series of keys
      clazz - the class that data wanted to be parsed for
      Returns:
      the wanted value as YAMLFileManager
    • getListAs

      public <T> List<T> getListAs(String key, Class<T> clazz)
      Fetch a single piece of data from the YAML file using a single key or a series of keys

      to support key series use a dot to separate keys "key1.key2" to support list in the key series "key[index]"

      Parameters:
      key - the path to the wanted data can be a single key or a series of keys
      clazz - the class that data wanted to be parsed for
      Returns:
      the wanted value as List<T>
    • getMapAs

      public <T> Map<String,T> getMapAs(String key, Class<T> clazz)
      Fetch a single piece of data from the YAML file using a single key or a series of keys

      to support key series use a dot to separate keys "key1.key2" to support list in the key series "key[index]"

      Parameters:
      key - the path to the wanted data can be a single key or a series of keys
      clazz - the class that data wanted to be parsed for
      Returns:
      the wanted value as Map of String and YAMLFileManager