Skip to content

Commit 3bad8ff

Browse files
Merge pull request #113 from oracle/object-javadoc
Fixing JavaDocs
2 parents 064efea + 2ad803e commit 3bad8ff

File tree

5 files changed

+108
-11
lines changed

5 files changed

+108
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ Publisher<Result> objectOutBindExample(Connection connection) {
697697
`oracle.r2dbc.OracleR2dbcObject`. The `OracleR2dbcObject` interface is a subtype
698698
of `io.r2dbc.spi.Readable`. Attribute values may be accessed using the standard
699699
`get` methods of `Readable`. The `get` methods of `OracleR2dbcObject` support
700-
alll SQL to Java type mappings defined by the
700+
all SQL to Java type mappings defined by the
701701
[R2DBC Specification](https://r2dbc.io/spec/1.0.0.RELEASE/spec/html/#datatypes.mapping):
702702
```java
703703
Publisher<Pet> objectMapExample(Result result) {

src/main/java/oracle/r2dbc/OracleR2dbcObject.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,59 @@
2020
*/
2121
package oracle.r2dbc;
2222

23+
/**
24+
* <p>
25+
* A {@link io.r2dbc.spi.Readable} that represents an instance of a user
26+
* defined OBJECT type.
27+
* </p><p>
28+
* An OBJECT returned by a {@link io.r2dbc.spi.Result} may be mapped to an
29+
* {@code OracleR2dbcObject}:
30+
* <pre>{@code
31+
* Publisher<Pet> objectMapExample(Result result) {
32+
* return result.map(row -> {
33+
*
34+
* OracleR2dbcObject oracleObject = row.get(0, OracleR2dbcObject.class);
35+
*
36+
* return new Pet(
37+
* oracleObject.get("name", String.class),
38+
* oracleObject.get("species", String.class),
39+
* oracleObject.get("weight", Float.class),
40+
* oracleObject.get("birthday", LocalDate.class));
41+
* });
42+
* }
43+
*
44+
* }</pre>
45+
* As seen in the example above, the values of an OBJECT's attributes may be
46+
* accessed by name with {@link #get(String)} or {@link #get(String, Class)}.
47+
* Alternatively, attribute values may be accessed by index with {@link #get(int)} or
48+
* {@link #get(int, Class)}. The {@code get} methods support all standard
49+
* SQL-to-Java type mappings defined by the
50+
* <a href="https://r2dbc.io/spec/1.0.0.RELEASE/spec/html/#datatypes.mapping">
51+
* R2DBC Specification.
52+
* </a>
53+
* <p>
54+
* Instances of {@code OracleR2dbcObject} may be set as a bind value when
55+
* passed to {@link io.r2dbc.spi.Statement#bind(int, Object)} or
56+
* {@link io.r2dbc.spi.Statement#bind(String, Object)}:
57+
* <pre>{@code
58+
* Publisher<Result> objectBindExample(
59+
* OracleR2dbcObject oracleObject, Connection connection) {
60+
*
61+
* Statement statement =
62+
* connection.createStatement("INSERT INTO petTable VALUES (:petObject)");
63+
*
64+
* statement.bind("petObject", oracleObject);
65+
*
66+
* return statement.execute();
67+
* }
68+
* }</pre>
69+
*/
2370
public interface OracleR2dbcObject extends io.r2dbc.spi.Readable {
2471

72+
/**
73+
* Returns metadata for the attributes of this OBJECT.
74+
* @return The metadata of this OBJECT's attributes. Not null.
75+
*/
2576
OracleR2dbcObjectMetadata getMetadata();
2677

2778
}

src/main/java/oracle/r2dbc/OracleR2dbcTypes.java

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private OracleR2dbcTypes() {}
114114
* name.
115115
* </p><p>
116116
* The {@code ArrayType} object returned by this method may be used to create
117-
* a {@link Parameter} that binds an array value to a {@link Statement}.
117+
* a {@link Parameter} that binds an array value to a {@link Statement}:
118118
* </p><pre>{@code
119119
* Publisher<Result> arrayBindExample(Connection connection) {
120120
* Statement statement =
@@ -137,6 +137,39 @@ public static ArrayType arrayType(String name) {
137137
return new ArrayTypeImpl(Objects.requireNonNull(name, "name is null"));
138138
}
139139

140+
/**
141+
* <p>
142+
* Creates an {@link ObjectType} representing a user defined {@code OBJECT}
143+
* type. The {@code name} passed to this method must identify the name of a
144+
* user defined {@code OBJECT} type.
145+
* </p><p>
146+
* Typically, the name passed to this method should be UPPER CASE, unless the
147+
* {@code CREATE TYPE} command that created the type used an "enquoted" type
148+
* name.
149+
* </p><p>
150+
* The {@code ObjectType} object returned by this method may be used to create
151+
* a {@link Parameter} that binds an OBJECT value to a {@link Statement}:
152+
* </p><pre>{@code
153+
* Publisher<Result> objectMapBindExample(Connection connection) {
154+
* Statement statement =
155+
* connection.createStatement("INSERT INTO petTable VALUES (:petObject)");
156+
*
157+
* // Bind the attributes of the PET OBJECT defined above
158+
* ObjectType objectType = OracleR2dbcTypes.objectType("PET");
159+
* Map<String,Object> attributeValues = Map.of(
160+
* "name", "Derby",
161+
* "species", "Dog",
162+
* "weight", 22.8,
163+
* "birthday", LocalDate.of(2015, 11, 07));
164+
* statement.bind("petObject", Parameters.in(objectType, attributeValues));
165+
*
166+
* return statement.execute();
167+
* }
168+
* }</pre>
169+
* @param name Name of a user defined OBJECT type. Not null.
170+
* @return A {@code Type} object representing the user defined OBJECT type.
171+
* Not null.
172+
*/
140173
public static ObjectType objectType(String name) {
141174
return new ObjectTypeImpl(Objects.requireNonNull(name, "name is null"));
142175
}
@@ -183,25 +216,32 @@ public interface ArrayType extends Type {
183216
String getName();
184217
}
185218

219+
/**
220+
* Extension of the standard {@link Type} interface used to represent user
221+
* defined OBJECT types. An instance of {@code ObjectType} must be used when
222+
* binding an OBJECT value to a {@link Statement} created by the Oracle R2DBC
223+
* Driver.
224+
*/
186225
public interface ObjectType extends Type {
187226

188227
/**
189228
* {@inheritDoc}
190-
* Returns {@code Object[].class}, which is the standard mapping for
191-
* {@link R2dbcType#COLLECTION}. The true default type mapping is the array
192-
* variant of the default mapping for the element type of the {@code ARRAY}.
193-
* For instance, an {@code ARRAY} of {@code VARCHAR} maps to a
194-
* {@code String[]} by default.
229+
* Returns the class of {@link OracleR2dbcObject}, which is the default mapping
230+
* of OBJECT types returned by Oracle R2DBC.
195231
*/
196232
@Override
197233
Class<?> getJavaType();
198234

199235
/**
200236
* {@inheritDoc}
201-
* Returns the name of this user defined {@code ARRAY} type. For instance,
202-
* this method returns "MY_ARRAY" if the type is declared as:
237+
* Returns the name of this user defined {@code OBJECT} type. For instance,
238+
* this method returns "PET" if the type is declared as:
203239
* <pre>{@code
204-
* CREATE TYPE MY_ARRAY AS ARRAY(8) OF NUMBER
240+
* CREATE TYPE PET AS OBJECT(
241+
* name VARCHAR(128),
242+
* species VARCHAR(128),
243+
* weight NUMBER,
244+
* birthday DATE)
205245
* }</pre>
206246
*/
207247
@Override

src/main/java/oracle/r2dbc/impl/OracleReadableImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ private OracleReadableImpl(
142142
* </p>
143143
* @param jdbcConnection JDBC connection that created the
144144
* {@code jdbcReadable}. Not null.
145+
* @param dependentCounter Counter that is increased for each dependent
146+
* {@code Result} created by the returned {@code Row}
145147
* @param jdbcReadable Row data from the Oracle JDBC Driver. Not null.
146148
* @param metadata Meta-data for the specified row. Not null.
147149
* @param adapter Adapts JDBC calls into reactive streams. Not null.
@@ -164,6 +166,8 @@ static Row createRow(
164166
* </p>
165167
* @param jdbcConnection JDBC connection that created the
166168
* {@code jdbcReadable}. Not null.
169+
* @param dependentCounter Counter that is increased for each dependent
170+
* {@code Result} created by the returned {@code OutParameters}
167171
* @param jdbcReadable Row data from the Oracle JDBC Driver. Not null.
168172
* @param metadata Meta-data for the specified row. Not null.
169173
* @param adapter Adapts JDBC calls into reactive streams. Not null.

src/main/java/oracle/r2dbc/impl/ReadablesMetadata.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ static RowMetadataImpl createRowMetadata(
105105
/**
106106
* Creates {@code OracleR2dbcObjectMetadata} that supplies attribute metadata
107107
* from a JDBC {@code OracleStruct} object.
108+
* @param oracleStruct Struct created by Oracle JDBC. Not null.
109+
* @return R2DBC metadata for the attributes of the struct. Not null.
108110
*/
109111
static OracleR2dbcObjectMetadataImpl createAttributeMetadata(
110112
OracleStruct oracleStruct) {
@@ -369,4 +371,4 @@ public boolean equals(Object other) {
369371
}
370372
}
371373

372-
}
374+
}

0 commit comments

Comments
 (0)