Skip to content

Commit

Permalink
Add JDs
Browse files Browse the repository at this point in the history
  • Loading branch information
sven1103 committed Sep 5, 2024
1 parent ccd03f2 commit 1c6fbb6
Showing 1 changed file with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,45 @@ public class PropertyToString {

private static final String ONTOLOGY_TERM = "%s [%s]"; // <term label> [CURIE]

/**
* Takes a {@link Condition} and transforms it into a String representation.
* <p>
* In its current implementation, the String representation results into a
* <code>;</code>-separated concatenation of {@link VariableLevel}. See
* {@link PropertyToString#variableLevel(VariableLevel)} for more details.
* <p>
* Example: a condition with the two variable levels <code>size: 20 cm</code> and <code>hue:
* blue</code> will result in:
* <p>
* <code>size: 20cm; hue: blue</code>
* <p>
* The generalised form is: <p>
* <code>[var name 1]: [level value 1] [unit 1];...; [var name N]: [level value N] [unit N];
* </code>
*
* @param condition the condition object to transform
* @return the String representation
* @since 1.5.0
*/
public static String condition(Condition condition) {
Objects.requireNonNull(condition);
List<String> stringValues = new ArrayList<>();
condition.getVariableLevels().forEach(variableLevel -> stringValues.add(variableLevel(variableLevel)));
condition.getVariableLevels()
.forEach(variableLevel -> stringValues.add(variableLevel(variableLevel)));
return String.join("; ", stringValues);
}

/**
* Takes a {@link VariableLevel} and transforms it into a String representation.
* <p>
* The generalised form of the output can be described with:
* <p>
* <code>[name]: [value] [unit]</code>
*
* @param variableLevel the variable level to transform
* @return the String representation of the variable level
* @since 1.5.0
*/
public static String variableLevel(VariableLevel variableLevel) {
Objects.requireNonNull(variableLevel);
if (variableLevel.experimentalValue().unit().isPresent()) {
Expand All @@ -42,6 +74,21 @@ public static String variableLevel(VariableLevel variableLevel) {
}
}

/**
* Transforms an {@link OntologyTerm} to its String representation.
* <p>
* The String representation currently contains the term label and the OBO ID.
* <p>
* The generalised form can be described as:
* <p>
* <code>[label] [[obo ID]]</code>
* <p>
* So e.g. 'Homo sapiens [NCBITaxon:9606]'
*
* @param ontologyTerm the ontology term to transform
* @return the String representation of the ontology term
* @since 1.5.0
*/
public static String ontologyTerm(OntologyTerm ontologyTerm) {
Objects.requireNonNull(ontologyTerm);
return ONTOLOGY_TERM.formatted(ontologyTerm.getLabel(), ontologyTerm.getOboId());
Expand Down

0 comments on commit 1c6fbb6

Please sign in to comment.