public class Utils extends Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static double |
divideDurations(Duration d1,
Duration d2)
Divide 2 durations to show one duration as a proportion of another
|
static <T> T |
oneOrNull(List<T> list)
Return the item from a single item list, or null if the list is empty.
|
static double |
ToSeconds(Duration d)
Convert a Duration into whole and fractional seconds
|
public static double divideDurations(Duration d1, Duration d2)
double result = Utils.divideDurations(Duration.ofSeconds(5), Duration.ofSeconds(10))
result = 0.5d1
- Duration 1d2
- Duration 2 the divisorpublic static double ToSeconds(Duration d)
d
- Durationpublic static <T> T oneOrNull(List<T> list)
SMF has many instances of triplets that specify the number of sections present. in most cases this API provides the sections in a List<SectionType>. In some cases there can be a maximum of one section and the number in the triplet simply indicates whether it is present or not. This is not always clearly documented in the SMF documentation.
This method is a convenience method that performs 2 functions:
list
- A list expected to have 1 or 0 membersIllegalArgumentException
- if there is more than 1 item in the listCopyright © 2020 Black Hill Software Pty Ltd. All rights reserved.