Skip to content

Commit

Permalink
Add class descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuel-keller committed Oct 16, 2024
1 parent 15b337c commit c456eb1
Show file tree
Hide file tree
Showing 19 changed files with 147 additions and 39 deletions.
5 changes: 5 additions & 0 deletions src/main/java/com/surrealdb/Array.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

import java.util.Iterator;

/**
* The Array class represents a native array structure and provides methods to
* interact with and retrieve values from the array.
* It implements the Iterable interface for Value type.
*/
public class Array extends Native implements Iterable<Value> {


Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/surrealdb/Entry.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.surrealdb;

/**
* Entry represents a key-value pair entry in a native data structure.
* <p>
* Entry provides methods to retrieve the key and value associated with the entry.
*/
public class Entry extends Native {

Entry(long ptr) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/surrealdb/EntryIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import java.util.Iterator;
import java.util.Objects;

/**
* EntryIterator is a specialized iterator for traversing entries.
* This class implements the Java Iterator interface to provide a seamless way to
* iterate over Entry objects.
*/
public class EntryIterator extends Native implements Iterator<Entry> {

EntryIterator(long ptr) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/surrealdb/Id.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.surrealdb;

/**
* The Id class represents a unique identifier that can be either a long value or a string.
*/
public class Id extends Native {

Id(long ptr) {
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/surrealdb/InsertRelation.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
import java.lang.Object;
import java.util.Objects;

/**
* The InsertRelation class represents a relationship between entities in a graph database.
* It is primarily used to insert relations into a table using SurrealDB.
* <p>
* This class encapsulates the identifiers for the relation, including the IDs for the entities that
* participate in the relationship. Specifically, it includes the following fields:
* <ul>
* <li>id: The unique identifier for the relation</li>
* <li>in: The RecordId of the incoming node in the relation</li>
* <li>out: The RecordId of the outgoing node in the relation</li>
* </ul>
* <p>
*/
public class InsertRelation {

public Id id;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/surrealdb/Object.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import java.util.Iterator;

/**
* The Object class implements the Iterable interface for Entry objects.
* It provides methods for object manipulation and interaction.
*/
public class Object extends Native implements Iterable<Entry> {

Object(long ptr) {
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/surrealdb/RecordId.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package com.surrealdb;

/**
* The RecordId class represents a unique identifier for a record in a database.
* <p>
* It provides methods to create and manipulate record IDs using either a table
* name and a long ID or a table name and a string ID. Additionally, it allows
* retrieval of the table associated with the ID and the ID itself.
*/
public class RecordId extends Native {


Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/surrealdb/Relation.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import java.lang.Object;
import java.util.Objects;

/**
* The Relation class represents a relationship between two records within a database.
* It holds the identifiers for the relationship itself and the two records it connects.
*/
public class Relation {

public RecordId id;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/surrealdb/Response.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import java.util.Objects;

/**
* The Response class is a specialized wrapper for handling responses from SurrealDB.
*/
public class Response extends Native {

Response(long ptr) {
Expand Down
58 changes: 21 additions & 37 deletions src/main/java/com/surrealdb/Surreal.java

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/main/java/com/surrealdb/SurrealException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.surrealdb;

/**
* The SurrealException class is a custom RuntimeException used to signal exceptional conditions.
*/
public class SurrealException extends RuntimeException {

SurrealException(String message) {
Expand All @@ -10,4 +13,4 @@ public class SurrealException extends RuntimeException {
super(message, cause);
}

}
}
29 changes: 28 additions & 1 deletion src/main/java/com/surrealdb/UpType.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
package com.surrealdb;

/**
* Enumeration to represent the type of update operations.
* <p>
* The UpType enum provides constants to specify the kind of update operation that should be performed.
*/
public enum UpType {

/**
* Represents a content update operation.
* This type of operation replaces the entire existing data with the provided data.
* <p>
* For more details, check the <a href="https://surrealdb.com/docs/surrealql/statements/update#content-clause">SurrealQL documentation</a>.
* <p>
*/
CONTENT(1),
/**
* Represents a merge update operation.
* This type of operation merges the existing data with the provided data.
* <p>
* For more details, check the <a href="https://surrealdb.com/docs/surrealql/statements/update#merge-clause">SurrealQL documentation</a>.
* <p>
*/
MERGE(2),
/**
* Represents a patch update operation.
* This type of operation applies partial changes to the existing data.
* <p>
* For more details, check the <a href="https://surrealdb.com/docs/surrealql/statements/update#patch-clause">SurrealQL documentation</a>.
* <p>
*/
PATCH(3);

final int code;

UpType(int code) {
this.code = code;
}

}
6 changes: 6 additions & 0 deletions src/main/java/com/surrealdb/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
import java.time.ZonedDateTime;
import java.util.UUID;

/**
* The Value class represents a general-purpose wrapper for different types of values.
* It provides various methods to
* interact with and retrieve values such as arrays, objects, strings,
* numbers, and more.
*/
public class Value extends Native {

Value(long ptr) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/surrealdb/ValueIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
import java.util.Iterator;
import java.util.Objects;

/**
* The ValueIterator class provides an iterator for the Value type, allowing iteration
* over a collection of Value objects, typically used within the context of array
* structures that extend the functionality provided by the library.
* <p>
* This class implements the Iterator interface for the
* Value type, enabling standard iteration mechanisms such as hasNext and next methods.
* <p>
* Methods:
* - hasNext(): Checks if there are more elements in the collection to iterate over.
* - next(): Returns the next Value in the iteration.
*/
public class ValueIterator extends Native implements Iterator<Value> {

ValueIterator(long ptr) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/surrealdb/signin/Database.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.surrealdb.signin;

/**
* The Database class represents a specific level of credentials for signing into a SurrealDB database.
* This class extends the Namespace class and adds a specific database reference, further scoping the sign-in process.
* <p>
* The credentials include username, password, namespace, and a specific database.
*/
public class Database extends Namespace implements Signin {

private final String database;
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/surrealdb/signin/Namespace.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.surrealdb.signin;

/**
* The Namespace class represents a specific level of credentials for signing into a SurrealDB namespace.
* This class extends the Root class and adds a namespace reference, further scoping the sign-in process.
* <p>
* The credentials include username, password, and a namespace.
*/
public class Namespace extends Root implements Signin {

private final String namespace;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/surrealdb/signin/Root.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.surrealdb.signin;

/**
* The Root class represents a level of credentials used for signing into the SurrealDB database.
* This class implements the Signin interface, providing the basic username and password authentication.
*/
public class Root implements Signin {

private final String username;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/surrealdb/signin/Signin.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
package com.surrealdb.signin;

/**
* The Signin interface is a marker interface used for classes that encapsulate
* credentials used for logging into the Surreal system.
* <p>
* The concrete implementations of this interface (i.e., Root, Namespace, and Database)
* determine the scope and type of the credentials being used for the sign-in process.
*/
public interface Signin {
}
4 changes: 4 additions & 0 deletions src/main/java/com/surrealdb/signin/Token.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.surrealdb.signin;

/**
* Represents a session token.
* This class is used to encapsulate a token string which can be used for authentication purposes.
*/
public class Token {

private final String token;
Expand Down

0 comments on commit c456eb1

Please sign in to comment.