@Override public LocalDateTime parseValue(Object input) { if (input instanceof LocalDateTime) { return (LocalDateTime) input; } else if (input instanceof String) { return Time.fromStorage((String) input); } else { return null; } }
@Override public String serialize(Object input) { if (input instanceof LocalDateTime) { return Time.forStorage((LocalDateTime) input); } else if (input instanceof String) { return (String) input; } else { return null; } }
private LocalDateTime toDateTime(Date date) { if (date == null) { return null; } else { return Time.from(date, null); } }
public static <T> T wait(String message, Future<T> task, long seconds) { try { return task.get(seconds, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new TaskInterruptedException(message); } catch (CancellationException e) { throw new TaskCancelledException(message); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } else { throw new TaskExecutionException(message, cause); } } catch (TimeoutException e) { throw new TaskTimeoutException(message, seconds); } } }
public static <T> T wait(String message, Optional<Future<? extends T>> task) { if (task.isPresent()) { return wait(message, task.get()); } else { throw new TaskNotScheduledException(message); } }
/** * Writes some bytes in Hexadecimal format * * @param bytes Bytes to format * @return Hex string */ public static String toHexString(byte[] bytes) { return toHexString(bytes, 0, bytes.length); }
public static <T> T wait(String message, Future<T> task) { return wait(message, task, 300); }
public static MapBuilder<String, Object> params() { return create(); }
protected AbstractLinkResourceDecorator(Class<T> resourceClass) { super(resourceClass); this.linkDefinitions = CachedSupplier.of(this::getLinkDefinitions); }
public TaskExecutionException(String message, Throwable cause) { super("Task was interrupted: %s", message); initCause(cause); }
public static boolean isValid(Document document) { return document != null && !document.isEmpty(); } }
public static <K, V> MapBuilder<K, V> create() { return new MapBuilder<K, V>(); }
public static <T> CachedSupplier<T> of(Supplier<T> inner) { return new CachedSupplier<>(inner); }
public static MapBuilder<String, Object> params(String key, Object value) { return of(key, value); }
protected static String dateTimeForDB(LocalDateTime time) { return Time.forStorage(time); }
protected static LocalDateTime dateTimeFromDB(String value) { return Time.fromStorage(value); }