blob: 20d66008457bddfb28a170c8df9f89566ffe895e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package pl.edu.mimuw.cloudatlas.model;
import java.util.List;
import java.util.Iterator;
public class ValueUtils {
public static boolean valueNonNullOfType(Value value, Type type) {
return value != null && !value.isNull() && value.getType().isCompatible(type);
}
public static boolean valueLower(Value a, Value b) {
return ((ValueBoolean) a.isLowerThan(b)).getValue();
}
public static ValueTime currentTime() {
return new ValueTime(System.currentTimeMillis());
}
public static ValueTime addToTime(ValueTime time, long millis) {
return time.addValue(new ValueDuration(millis));
}
public static boolean isPrefix(PathName prefix, PathName path) {
List<String> prefixComponents = prefix.getComponents();
List<String> pathComponents = path.getComponents();
if (prefixComponents.size() > pathComponents.size()) {
return false;
}
Iterator<String> prefixIterator = prefixComponents.iterator();
Iterator<String> pathIterator = pathComponents.iterator();
while (prefixIterator.hasNext()) {
if (!prefixIterator.next().equals(pathIterator.next())) {
return false;
}
}
return true;
}
}
|