m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu/mimuw/cloudatlas/model
diff options
context:
space:
mode:
authorMagdalena GrodziƄska <mag.grodzinska@gmail.com>2020-01-12 22:58:53 +0100
committerGitHub <noreply@github.com>2020-01-12 22:58:53 +0100
commit39d7f8b70dfef38e4b6169e53fb7066743d734d4 (patch)
tree56f6843f62ff881628148e92ad068785e7b69166 /src/main/java/pl/edu/mimuw/cloudatlas/model
parentc48ec1604744ab330d18af1f55256c35dc5c34c6 (diff)
parent0f31d1f5c267f893d765ccd848b95fc111009de5 (diff)
Merge branch 'master' into query_signer
Diffstat (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/model')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/model/Type.java2
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/model/TypePrimitive.java2
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java2
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/model/ValueUtils.java22
4 files changed, 28 insertions, 0 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/model/Type.java b/src/main/java/pl/edu/mimuw/cloudatlas/model/Type.java
index 0994cba..4453aea 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/model/Type.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/model/Type.java
@@ -49,6 +49,8 @@ public abstract class Type implements Serializable {
this.primaryType = primaryType;
}
+ public Type() { this.primaryType = PrimaryType.NULL; };
+
/**
* Returns the primary type of this type.
*
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/model/TypePrimitive.java b/src/main/java/pl/edu/mimuw/cloudatlas/model/TypePrimitive.java
index ad07c0a..a17cafa 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/model/TypePrimitive.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/model/TypePrimitive.java
@@ -78,6 +78,8 @@ public class TypePrimitive extends Type {
*/
public static final TypePrimitive QUERY = new TypePrimitive(PrimaryType.QUERY);
+ private TypePrimitive() {}
+
private TypePrimitive(PrimaryType primaryType) {
super(primaryType);
switch(primaryType) {
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java b/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java
index 26a5fbb..c5d4b54 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java
@@ -49,6 +49,8 @@ public class ValueQuery extends Value {
this.timestamp = System.currentTimeMillis();
}
+ public String getCode() { return code; }
+
public Program getQuery() {
return query;
}
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueUtils.java b/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueUtils.java
index 866349f..20d6600 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueUtils.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueUtils.java
@@ -1,5 +1,8 @@
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);
@@ -16,4 +19,23 @@ public class ValueUtils {
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;
+ }
}