-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: include semistructured project
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
- Loading branch information
1 parent
e50f290
commit 110cc36
Showing
52 changed files
with
8,208 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
jnosql-communication/jnosql-communication-semistructured/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
pom.xml.next | ||
test-output/ | ||
/doc | ||
*.iml | ||
*.idea | ||
*.log | ||
.classpath | ||
-project | ||
/.resourceCache | ||
/.project | ||
/.idea | ||
.settings/ |
39 changes: 39 additions & 0 deletions
39
jnosql-communication/jnosql-communication-semistructured/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ | ||
~ Copyright (c) 2022 Contributors to the Eclipse Foundation | ||
~ All rights reserved. This program and the accompanying materials | ||
~ are made available under the terms of the Eclipse Public License v1.0 | ||
~ and Apache License v2.0 which accompanies this distribution. | ||
~ The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
~ and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. | ||
~ | ||
~ You may elect to redistribute this code under either of these licenses. | ||
~ | ||
~ Contributors: | ||
~ | ||
~ Otavio Santana | ||
~ | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.eclipse.jnosql.communication</groupId> | ||
<artifactId>jnosql-communication</artifactId> | ||
<version>1.1.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>jnosql-communication-semistructured</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>jnosql-communication-query</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
22 changes: 22 additions & 0 deletions
22
jnosql-communication/jnosql-communication-semistructured/src/main/java/module-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
/* | ||
* Copyright (c) 2022 Contributors to the Eclipse Foundation | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. | ||
* You may elect to redistribute this code under either of these licenses. | ||
* Contributors: | ||
* Otavio Santana | ||
*/ | ||
module org.eclipse.jnosql.communication.column { | ||
requires org.eclipse.jnosql.communication.core; | ||
requires org.eclipse.jnosql.communication.query; | ||
requires jakarta.json.bind; | ||
requires jakarta.json; | ||
requires jakarta.data; | ||
|
||
opens org.eclipse.jnosql.communication.column; | ||
|
||
} |
108 changes: 108 additions & 0 deletions
108
...emistructured/src/main/java/org/eclipse/jnosql/communication/column/BaseQueryBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* | ||
* Copyright (c) 2022 Contributors to the Eclipse Foundation | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
* | ||
* Contributors: | ||
* | ||
* Otavio Santana | ||
* | ||
*/ | ||
package org.eclipse.jnosql.communication.column; | ||
|
||
|
||
import static java.util.Arrays.asList; | ||
import static java.util.Objects.nonNull; | ||
import static java.util.Objects.requireNonNull; | ||
|
||
abstract class BaseQueryBuilder { | ||
|
||
protected String name; | ||
|
||
protected boolean negate; | ||
|
||
protected boolean and; | ||
|
||
protected ColumnCondition condition; | ||
|
||
protected <T> void eqImpl(T value) { | ||
requireNonNull(value, "value is required"); | ||
ColumnCondition newCondition = ColumnCondition.eq(Column.of(name, value)); | ||
appendCondition(newCondition); | ||
} | ||
|
||
protected <T> void gtImpl(T value) { | ||
requireNonNull(value, "value is required"); | ||
ColumnCondition newCondition = ColumnCondition.gt(Column.of(name, value)); | ||
appendCondition(newCondition); | ||
} | ||
|
||
protected void likeImpl(String value) { | ||
requireNonNull(value, "value is required"); | ||
ColumnCondition newCondition = ColumnCondition.like(Column.of(name, value)); | ||
appendCondition(newCondition); | ||
} | ||
|
||
protected <T> void ltImpl(T value) { | ||
requireNonNull(value, "value is required"); | ||
ColumnCondition newCondition = ColumnCondition.lt(Column.of(name, value)); | ||
appendCondition(newCondition); | ||
} | ||
|
||
protected <T> void lteImpl(T value) { | ||
requireNonNull(value, "value is required"); | ||
ColumnCondition newCondition = ColumnCondition.lte(Column.of(name, value)); | ||
appendCondition(newCondition); | ||
} | ||
|
||
protected <T> void gteImpl(T value) { | ||
requireNonNull(value, "value is required"); | ||
ColumnCondition newCondition = ColumnCondition.gte(Column.of(name, value)); | ||
appendCondition(newCondition); | ||
} | ||
|
||
protected <T> void betweenImpl(T valueA, T valueB) { | ||
requireNonNull(valueA, "valueA is required"); | ||
requireNonNull(valueB, "valueB is required"); | ||
ColumnCondition newCondition = ColumnCondition.between(Column.of(name, asList(valueA, valueB))); | ||
appendCondition(newCondition); | ||
} | ||
|
||
protected <T> void inImpl(Iterable<T> values) { | ||
requireNonNull(values, "values is required"); | ||
ColumnCondition newCondition = ColumnCondition.in(Column.of(name, values)); | ||
appendCondition(newCondition); | ||
} | ||
|
||
|
||
protected void appendCondition(ColumnCondition newCondition) { | ||
|
||
ColumnCondition columnCondition = getColumnCondition(newCondition); | ||
|
||
if (nonNull(condition)) { | ||
if (and) { | ||
this.condition = condition.and(columnCondition); | ||
} else { | ||
this.condition = condition.or(columnCondition); | ||
} | ||
} else { | ||
this.condition = columnCondition; | ||
} | ||
this.negate = false; | ||
this.name = null; | ||
} | ||
|
||
private ColumnCondition getColumnCondition(ColumnCondition newCondition) { | ||
if (negate) { | ||
return newCondition.negate(); | ||
} else { | ||
return newCondition; | ||
} | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...nication-semistructured/src/main/java/org/eclipse/jnosql/communication/column/Column.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* | ||
* Copyright (c) 2022 Contributors to the Eclipse Foundation | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
* | ||
* Contributors: | ||
* | ||
* Otavio Santana | ||
* | ||
*/ | ||
package org.eclipse.jnosql.communication.column; | ||
|
||
import org.eclipse.jnosql.communication.Entry; | ||
import org.eclipse.jnosql.communication.TypeSupplier; | ||
import org.eclipse.jnosql.communication.Value; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* A Column is a tuple (pair) that consists of the name and its respective value. | ||
* A {@link ColumnEntity} has one or more Columns. | ||
*/ | ||
public interface Column extends Entry { | ||
/** | ||
* Alias to {@link Value#get(Class)} | ||
* | ||
* @param type the type class | ||
* @param <T> the instance type | ||
* @return {@link Value#get(Class)} | ||
* @throws NullPointerException see {@link Value#get(Class)} | ||
* @throws UnsupportedOperationException see {@link Value#get(Class)} | ||
*/ | ||
<T> T get(Class<T> type) ; | ||
|
||
/** | ||
* Alias to {@link Value#get(TypeSupplier)} | ||
* | ||
* @param supplier {@link Value#get(Class)} | ||
* @param <T> {@link Value#get(Class)} | ||
* @return {@link Value#get(TypeSupplier)} | ||
* @throws NullPointerException see {@link Value#get(Class)} | ||
* @throws UnsupportedOperationException see {@link Value#get(Class)} | ||
*/ | ||
<T> T get(TypeSupplier<T> supplier); | ||
|
||
/** | ||
* Alias to {@link Value#get()} | ||
* | ||
* @return {@link Value#get()} | ||
*/ | ||
Object get(); | ||
|
||
|
||
/** | ||
* Creates a column instance | ||
* | ||
* @param name - column's name | ||
* @param value - column's value | ||
* @param <V> the value type | ||
* @return a column instance | ||
* @throws NullPointerException when name is null | ||
* @see Columns | ||
*/ | ||
static <V> Column of(String name, V value) { | ||
Objects.requireNonNull(name, "name is required"); | ||
return new DefaultColumn(name, getValue(value)); | ||
} | ||
|
||
private static Value getValue(Object value) { | ||
if (value instanceof Value) { | ||
return (Value) value; | ||
} else { | ||
return Value.of(value); | ||
} | ||
} | ||
} |
Oops, something went wrong.