com.ninja_squad.dbsetup.destination
Class DataSourceDestination

java.lang.Object
  extended by com.ninja_squad.dbsetup.destination.DataSourceDestination
All Implemented Interfaces:
Destination

@Immutable
public final class DataSourceDestination
extends java.lang.Object
implements Destination

A destination which wraps a DataSource and gets its connection from the wrapped DataSource


Constructor Summary
DataSourceDestination(javax.sql.DataSource dataSource)
          Constructor
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.sql.Connection getConnection()
          Returns a connection to the destination database
 int hashCode()
           
 java.lang.String toString()
           
static DataSourceDestination with(javax.sql.DataSource dataSource)
          Factory method creating a new DataSourceDestination.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataSourceDestination

public DataSourceDestination(@Nonnull
                             javax.sql.DataSource dataSource)
Constructor

Parameters:
dataSource - the wrapped DataSource
Method Detail

with

public static DataSourceDestination with(@Nonnull
                                         javax.sql.DataSource dataSource)
Factory method creating a new DataSourceDestination. This allows a more readable style than using the constructor:
    DbSetup dbSetup = new DbSetup(DataSourceDestination.with(dataSource), operation);
 
or, if this method is statically imported:
    DbSetup dbSetup = new DbSetup(with(dataSource), operation);
 
instead of
    DbSetup dbSetup = new DbSetup(new DataSourceDestination(dataSource), operation);
 

Parameters:
dataSource - the wrapped DataSource

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Description copied from interface: Destination
Returns a connection to the destination database

Specified by:
getConnection in interface Destination
Returns:
a connection to the destination database
Throws:
java.sql.SQLException - if a connection can't be returned

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object