diff --git a/concourse-driver-java/src/main/java/com/cinchapi/concourse/Point.java b/concourse-driver-java/src/main/java/com/cinchapi/concourse/Point.java new file mode 100644 index 0000000000..f29ca3f04d --- /dev/null +++ b/concourse-driver-java/src/main/java/com/cinchapi/concourse/Point.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2013-2019 Cinchapi Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.cinchapi.concourse; + +import javax.annotation.concurrent.Immutable; + +/** + * A {@link Point} is a data type which harbors 2-doubles. + *

+ * A Point represents a specific location. + *

+ */ +@Immutable +public final class Point { + + private double x; + private double y; + + public Point(double x, double y) { + this.x = x; + this.y = y; + } + + public static Point to(float x, float y) { + return new Point(x, y); + } + + public double y() { + return y; + } + + public double x() { + return x; + } + +} diff --git a/concourse-driver-java/src/main/java/com/cinchapi/concourse/thrift/Type.java b/concourse-driver-java/src/main/java/com/cinchapi/concourse/thrift/Type.java index 97c9b29651..39dade0fa7 100644 --- a/concourse-driver-java/src/main/java/com/cinchapi/concourse/thrift/Type.java +++ b/concourse-driver-java/src/main/java/com/cinchapi/concourse/thrift/Type.java @@ -28,7 +28,8 @@ public enum Type implements org.apache.thrift.TEnum { STRING(7), TAG(8), NULL(9), - TIMESTAMP(10); + TIMESTAMP(10), + POINT(11); private final int value; @@ -70,6 +71,8 @@ public static Type findByValue(int value) { return NULL; case 10: return TIMESTAMP; + case 11: + return POINT; default: return null; } diff --git a/concourse-driver-java/src/main/java/com/cinchapi/concourse/util/Convert.java b/concourse-driver-java/src/main/java/com/cinchapi/concourse/util/Convert.java index 24902fab8c..afda7e2cb1 100644 --- a/concourse-driver-java/src/main/java/com/cinchapi/concourse/util/Convert.java +++ b/concourse-driver-java/src/main/java/com/cinchapi/concourse/util/Convert.java @@ -37,6 +37,7 @@ import com.cinchapi.common.base.CheckedExceptions; import com.cinchapi.concourse.Concourse; import com.cinchapi.concourse.Link; +import com.cinchapi.concourse.Point; import com.cinchapi.concourse.Tag; import com.cinchapi.concourse.Timestamp; import com.cinchapi.concourse.annotate.PackagePrivate; @@ -247,6 +248,12 @@ else if(object instanceof Timestamp) { "Cannot convert string based Timestamp to a TObject"); } } + else if(object instanceof Point) { + bytes = ByteBuffer.allocate(16); + bytes.putFloat(((Point) object).getX()); + bytes.putFloat(((Point) object).getY()); + type = Type.POINT; + } else { bytes = ByteBuffer.wrap( object.toString().getBytes(StandardCharsets.UTF_8)); diff --git a/interface/shared.thrift b/interface/shared.thrift index 4eda83931f..4b6bebcde3 100644 --- a/interface/shared.thrift +++ b/interface/shared.thrift @@ -65,6 +65,7 @@ enum Type { TAG = 8, NULL = 9, TIMESTAMP = 10, + POINT = 11 } /** When re-constructing the state of a record/field/index from some base state,