001/* 002 * Copyright 2015-2022 Transmogrify LLC, 2022-2026 Revetware LLC. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.pyranid; 018 019import org.jspecify.annotations.NonNull; 020 021import javax.annotation.concurrent.ThreadSafe; 022import java.util.List; 023import java.util.Optional; 024 025/** 026 * Encapsulates {@link java.sql.PreparedStatement} parameter data meant to be bound to a vector type (for example, PostgreSQL's <a href="https://github.com/pgvector/pgvector" target="_blank">{@code pgvector}</a>), by {@link PreparedStatementBinder}. 027 * <p> 028 * Stardard instances may be constructed via the following factory methods: 029 * <ul> 030 * <li>{@link Parameters#vectorOfFloats(float[])}</li> 031 * <li>{@link Parameters#vectorOfFloats(List)}</li> 032 * <li>{@link Parameters#vectorOfDoubles(double[])}</li> 033 * <li>{@link Parameters#vectorOfDoubles(List)}</li> 034 * <li>{@link Parameters#vectorOfBigDecimals(List)}</li> 035 * </ul> 036 * Implementations should be threadsafe. 037 * 038 * @author <a href="https://www.revetkn.com">Mark Allen</a> 039 * @since 3.0.0 040 */ 041@ThreadSafe 042public interface VectorParameter { 043 /** 044 * Gets the elements of this vector. 045 * 046 * @return the elements of this vector 047 */ 048 @NonNull 049 Optional<double[]> getElements(); 050}