diff --git a/user-interface/src/main/java/life/qbic/datamanager/parser/PropertyToString.java b/user-interface/src/main/java/life/qbic/datamanager/parser/PropertyToString.java index 223dbbf72..a59e30ba0 100644 --- a/user-interface/src/main/java/life/qbic/datamanager/parser/PropertyToString.java +++ b/user-interface/src/main/java/life/qbic/datamanager/parser/PropertyToString.java @@ -23,13 +23,45 @@ public class PropertyToString { private static final String ONTOLOGY_TERM = "%s [%s]"; // [CURIE] + /** + * Takes a {@link Condition} and transforms it into a String representation. + *

+ * In its current implementation, the String representation results into a + * ;-separated concatenation of {@link VariableLevel}. See + * {@link PropertyToString#variableLevel(VariableLevel)} for more details. + *

+ * Example: a condition with the two variable levels size: 20 cm and hue: + * blue will result in: + *

+ * size: 20cm; hue: blue + *

+ * The generalised form is:

+ * [var name 1]: [level value 1] [unit 1];...; [var name N]: [level value N] [unit N]; + * + * + * @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 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. + *

+ * The generalised form of the output can be described with: + *

+ * [name]: [value] [unit] + * + * @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()) { @@ -42,6 +74,21 @@ public static String variableLevel(VariableLevel variableLevel) { } } + /** + * Transforms an {@link OntologyTerm} to its String representation. + *

+ * The String representation currently contains the term label and the OBO ID. + *

+ * The generalised form can be described as: + *

+ * [label] [[obo ID]] + *

+ * 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());