completed CRUD operations
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -70,6 +70,7 @@ public abstract class BaseImporter implements Importer {
|
||||
return Error.of("not implemented");
|
||||
}
|
||||
|
||||
|
||||
protected Result<LocalDateTime> extractEnd(Tag eventTag) {
|
||||
Result<Tag> endTag = extractEndTag(eventTag);
|
||||
if (endTag.optional().isEmpty()) return transform(endTag);
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/* © SRSoftware 2024 */
|
||||
package de.srsoftware.cal;
|
||||
|
||||
import de.srsoftware.cal.api.Coords;
|
||||
import de.srsoftware.tools.Error;
|
||||
import de.srsoftware.tools.Payload;
|
||||
import de.srsoftware.tools.Result;
|
||||
|
||||
public class Util {
|
||||
public static Result<Coords> extractCoords(String coords) {
|
||||
if (coords == null) return de.srsoftware.tools.Error.of("Argument is null");
|
||||
if (coords.isBlank()) return de.srsoftware.tools.Error.of("Argument is blank");
|
||||
var parts = coords.split(",");
|
||||
if (parts.length != 2) return de.srsoftware.tools.Error.format("Argument has invalid format: %s", coords);
|
||||
try {
|
||||
var lat = Double.parseDouble(parts[0].trim());
|
||||
var lon = Double.parseDouble(parts[1].trim());
|
||||
return Payload.of(new Coords(lon, lat));
|
||||
} catch (NumberFormatException nfe) {
|
||||
return Error.of("Failed to parse coords from %s".formatted(coords), nfe);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user