com.julienviet.pgclient.Tuple Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of reactive-pg-client Show documentation
Show all versions of reactive-pg-client Show documentation
The reactive Postgres client
/*
* Copyright (C) 2017 Julien Viet
*
* 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.julienviet.pgclient;
import com.julienviet.pgclient.impl.ArrayTuple;
import io.vertx.codegen.annotations.Fluent;
import io.vertx.codegen.annotations.GenIgnore;
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.temporal.Temporal;
import java.util.UUID;
/**
* A general purpose tuple.
*/
@VertxGen
public interface Tuple {
/**
* @return a new empty tuple
*/
static Tuple tuple() {
return new ArrayTuple(10);
}
/**
* Create a tuple of one element.
*
* @param elt1 the first value
* @return the tuple
*/
static Tuple of(Object elt1) {
ArrayTuple tuple = new ArrayTuple(1);
tuple.addValue(elt1);
return tuple;
}
/**
* Create a tuple of two elements.
*
* @param elt1 the first value
* @param elt2 the second value
* @return the tuple
*/
static Tuple of(Object elt1, Object elt2) {
ArrayTuple tuple = new ArrayTuple(2);
tuple.addValue(elt1);
tuple.addValue(elt2);
return tuple;
}
/**
* Create a tuple of three elements.
*
* @param elt1 the first value
* @param elt2 the second value
* @param elt3 the third value
* @return the tuple
*/
static Tuple of(Object elt1, Object elt2, Object elt3) {
ArrayTuple tuple = new ArrayTuple(3);
tuple.addValue(elt1);
tuple.addValue(elt2);
tuple.addValue(elt3);
return tuple;
}
/**
* Create a tuple of four elements.
*
* @param elt1 the first value
* @param elt2 the second value
* @param elt3 the third value
* @param elt4 the fourth value
* @return the tuple
*/
static Tuple of(Object elt1, Object elt2, Object elt3, Object elt4) {
ArrayTuple tuple = new ArrayTuple(4);
tuple.addValue(elt1);
tuple.addValue(elt2);
tuple.addValue(elt3);
tuple.addValue(elt4);
return tuple;
}
/**
* Create a tuple of five elements.
*
* @param elt1 the first value
* @param elt2 the second value
* @param elt3 the third value
* @param elt4 the fourth value
* @param elt5 the fifth value
* @return the tuple
*/
static Tuple of(Object elt1, Object elt2, Object elt3, Object elt4, Object elt5) {
ArrayTuple tuple = new ArrayTuple(5);
tuple.addValue(elt1);
tuple.addValue(elt2);
tuple.addValue(elt3);
tuple.addValue(elt4);
tuple.addValue(elt5);
return tuple;
}
/**
* Create a tuple of six elements.
*
* @param elt1 the first value
* @param elt2 the second value
* @param elt3 the third value
* @param elt4 the fourth value
* @param elt5 the fifth value
* @param elt5 the sixth value
* @return the tuple
*/
static Tuple of(Object elt1, Object elt2, Object elt3, Object elt4, Object elt5, Object elt6) {
ArrayTuple tuple = new ArrayTuple(5);
tuple.addValue(elt1);
tuple.addValue(elt2);
tuple.addValue(elt3);
tuple.addValue(elt4);
tuple.addValue(elt5);
tuple.addValue(elt6);
return tuple;
}
/**
* Create a tuple of an arbitrary number of elements.
*
* @param elements the elements
* @return the tuple
*/
@GenIgnore
static Tuple of(Object... elements) {
ArrayTuple tuple = new ArrayTuple(elements.length);
for (Object elt: elements) {
tuple.addValue(elt);
}
return tuple;
}
/**
* Get a boolean value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
Boolean getBoolean(int pos);
/**
* Get an object value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
Object getValue(int pos);
/**
* Get an integer value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
Integer getInteger(int pos);
/**
* Get a long value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
Long getLong(int pos);
/**
* Get a float value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
Float getFloat(int pos);
/**
* Get a double value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
Double getDouble(int pos);
/**
* Get a string value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
String getString(int pos);
/**
* Get a {@link Character} value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
Character getCharacter(int pos);
/**
* Get a json object value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
JsonObject getJsonObject(int pos);
/**
* Get a json array value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
JsonArray getJsonArray(int pos);
/**
* Get a {@link java.time.temporal.Temporal} value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
@GenIgnore
Temporal getTemporal(int pos);
/**
* Get {@link java.time.LocalDate} value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
@GenIgnore
LocalDate getLocalDate(int pos);
/**
* Get {@link java.time.LocalTime} value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
@GenIgnore
LocalTime getLocalTime(int pos);
/**
* Get {@link java.time.LocalDateTime} value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
@GenIgnore
LocalDateTime getLocalDateTime(int pos);
/**
* Get {@link java.time.OffsetTime} value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
@GenIgnore
OffsetTime getOffsetTime(int pos);
/**
* Get {@link java.time.OffsetDateTime} value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
@GenIgnore
OffsetDateTime getOffsetDateTime(int pos);
/**
* Get {@link java.util.UUID} value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
@GenIgnore
UUID getUUID(int pos);
/**
* Get {@link BigDecimal} value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
@GenIgnore
BigDecimal getBigDecimal(int pos);
/**
* Get a buffer value at {@code pos}.
*
* @param pos the position
* @return the value or {@code null}
*/
Buffer getBuffer(int pos);
/**
* Add a boolean value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@Fluent
Tuple addBoolean(Boolean value);
/**
* Add an object value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@Fluent
Tuple addValue(Object value);
/**
* Add an integer value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@Fluent
Tuple addInteger(Integer value);
/**
* Add a long value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@Fluent
Tuple addLong(Long value);
/**
* Add a float value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@Fluent
Tuple addFloat(Float value);
/**
* Add a double value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@Fluent
Tuple addDouble(Double value);
/**
* Add a string value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@Fluent
Tuple addString(String value);
/**
* Add a {@link Character} value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@Fluent
Tuple addCharacter(Character value);
/**
* Add a json object value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@Fluent
Tuple addJsonObject(JsonObject value);
/**
* Add a json array value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@Fluent
Tuple addJsonArray(JsonArray value);
/**
* Add a buffer value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@Fluent
Tuple addBuffer(Buffer value);
/**
* Add a {@link java.time.temporal.Temporal} value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@GenIgnore
Tuple addTemporal(Temporal value);
/**
* Add a {@link java.time.LocalDate} value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@GenIgnore
Tuple addLocalDate(LocalDate value);
/**
* Add a {@link java.time.LocalTime} value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@GenIgnore
Tuple addLocalTime(LocalTime value);
/**
* Add a {@link java.time.LocalDateTime} value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@GenIgnore
Tuple addLocalDateTime(LocalDateTime value);
/**
* Add a {@link java.time.OffsetTime} value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@GenIgnore
Tuple addOffsetTime(OffsetTime value);
/**
* Add a {@link java.time.OffsetDateTime} value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@GenIgnore
Tuple addOffsetDateTime(OffsetDateTime value);
/**
* Add a {@link java.util.UUID} value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@GenIgnore
Tuple addUUID(UUID value);
/**
* Add a {@link BigDecimal} value at the end of the tuple.
*
* @param value the value
* @return a reference to this, so the API can be used fluently
*/
@GenIgnore
Tuple addBigDecimal(BigDecimal value);
/**
* @return the tuple size
*/
int size();
}