Class SSSOMTListItemFunction

java.lang.Object
org.incenp.obofoundry.sssom.transform.SSSOMTListItemFunction
All Implemented Interfaces:
IFormatModifierFunction

public class SSSOMTListItemFunction extends Object implements IFormatModifierFunction
Represents the SSSOM/T modifier function "list_item".

Use this function to extract a single item from a list-typed value. It accepts a single argument which should be 1-based index of the item to extract.

For example, to get the second author ID of a mapping:

 "Second author: %{author_id|list_item(2)}"
 
  • Constructor Details

    • SSSOMTListItemFunction

      public SSSOMTListItemFunction()
  • Method Details

    • getName

      public String getName()
      Description copied from interface: IFormatModifierFunction
      Gets the name by which the function should be called in a placeholder.
      Specified by:
      getName in interface IFormatModifierFunction
      Returns:
      The function name.
    • getSignature

      public String getSignature()
      Description copied from interface: IFormatModifierFunction
      Gets the expected signature of the function. This works similarly to ISSSOMTFunction.getSignature(), but it only concerns the additional arguments beyond the value of the substituted placeholder to modify (e.g. extra_arg1 in the example above).
      Specified by:
      getSignature in interface IFormatModifierFunction
      Returns:
      The function signature.
    • call

      public Object call(Object value, List<String> extra)
      Description copied from interface: IFormatModifierFunction
      Executes the function.
      Specified by:
      call in interface IFormatModifierFunction
      Parameters:
      value - The original value this function is supposed to modify. It is guaranteed never to be null, but the exact type will depend on what the substituted placeholder was, and also on what any previous modifier function may have done with it.
      extra - Additional arguments to the function, if any. If the function declared that it expects some mandatory arguments (through the IFormatModifierFunction.getSignature() method), it is guaranteed the list will contains as many arguments as expected.
      Returns:
      The modified value. It may not need be of the same type as the original value (e.g., a function could transform a list value into a string value).