Skip to content

Commit

Permalink
docs: create documentation to builder supplier
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed Jul 31, 2023
1 parent 6a5cabb commit adb47f6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
package org.eclipse.jnosql.mapping.reflection;


import jakarta.nosql.NoSQLException;
import org.eclipse.jnosql.mapping.metadata.ParameterMetaData;

import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.ServiceLoader;

/**
* The ConstructorBuilder interface provides a way to create an entity from a constructor.
Expand Down Expand Up @@ -55,4 +59,16 @@ public interface ConstructorBuilder {
*/
<T> T build();

/**
* Creates a new instance of the {@link ConstructorBuilder} interface using the provided
* * {@link ConstructorMetadata}.
* @param constructor the constructor
* @return the ConstructorBuilder instance
*/
static ConstructorBuilder of(ConstructorMetadata constructor){
Objects.requireNonNull(constructor, "constructor is required");
var supplier = ServiceLoader.load(ConstructorBuilderSupplier.class).findFirst()
.orElseThrow(() -> new NoSQLException("There is not implementation for the ConstructorBuilderSupplier"));
return supplier.apply(constructor);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2023 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.mapping.reflection;

import java.util.function.Function;

/**
* A supplier that create a ConstructorBuilder from the ConstructorMetadata.
*/
public interface ConstructorBuilderSupplier extends Function<ConstructorMetadata, ConstructorBuilder> {
}

0 comments on commit adb47f6

Please sign in to comment.