Java Code Examples for io.vertx.sqlclient.PropertyKind

The following examples show how to use io.vertx.sqlclient.PropertyKind. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Loads MySQLClient.LAST_INSERTED_ID via reflection to avoid a hard
 * dependency on the MySQL driver
 */
@SuppressWarnings("unchecked")
private static PropertyKind<Long> getMySqlLastInsertedId() {
    if (mySqlLastInsertedId == null) {
           try {
               Class<?> MySQLClient = Class.forName( "io.vertx.mysqlclient.MySQLClient" );
               mySqlLastInsertedId = (PropertyKind<Long>) MySQLClient.getField( "LAST_INSERTED_ID" ).get( null );
           } catch (ClassNotFoundException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException | SecurityException e) {
               throw new RuntimeException( "Unable to obtain MySQLClient.LAST_INSERTED_ID field", e );
           }
       }
       return mySqlLastInsertedId;
   }
 
Example 2
Source Project: vertx-sql-client   Source File: QueryResultBuilder.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public <V> void addProperty(PropertyKind<V> property, V value) {
  R r = this.current;
  if (r != null) {
    if (r.properties == null) {
      // lazy init
      r.properties = new HashMap<>();
    }
    r.properties.put(property, value);
  }
}
 
Example 3
Source Project: vertx-sql-client   Source File: SqlResultTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testNullProperties() {
  RowSetImpl rowSet = new RowSetImpl();
  rowSet.properties = null;
  PropertyKind<String> propertyKind = () -> String.class;
  Assert.assertNull(rowSet.property(propertyKind));
}
 
Example 4
Source Project: vertx-sql-client   Source File: SqlResultTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testPropertyKindNullType() {
  RowSetImpl rowSet = new RowSetImpl();
  rowSet.properties = new HashMap<>();
  PropertyKind<String> nullTypePropertyKind = () -> null;
  try {
    rowSet.property(nullTypePropertyKind);
  } catch (NullPointerException ignored) {
    // NPE
  }
}
 
Example 5
Source Project: vertx-sql-client   Source File: SqlResultTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testUnknownPropertyKind() {
  RowSetImpl rowSet = new RowSetImpl();
  PropertyKind<Integer> knownPropertyKind = () -> Integer.class;
  PropertyKind<String> unknownPropertyKind = () -> String.class;
  rowSet.properties = new HashMap<>();
  rowSet.properties.put(knownPropertyKind, 1234);

  Assert.assertEquals(Integer.valueOf(1234), rowSet.property(knownPropertyKind));
  Assert.assertNull(rowSet.property(unknownPropertyKind));
}
 
Example 6
Source Project: vertx-sql-client   Source File: QueryResultHandler.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public <V> void addProperty(PropertyKind<V> property, V value) {
}
 
Example 7
Source Project: raml-module-builder   Source File: LocalRowSet.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public <V> V property(PropertyKind<V> propertyKind) {
  return null;
}
 
Example 8
Source Project: vertx-sql-client   Source File: QueryResultHandler.java    License: Apache License 2.0 votes vote down vote up
<V> void addProperty(PropertyKind<V> property, V value);