// Path: src/main/java/io/github/tjheslin1/patterdale/ValueType.java
// public abstract class ValueType {
// 
//     /**
//      * @param object The object to be compared to this instance.
//      * @return true if this instance matches the 'object'. Calculated reflectively on the fields.
//      */
//     @Override
//     public boolean equals(Object object) {
//         return EqualsBuilder.reflectionEquals(this, object);
//     }
// 
//     /**
//      * Reflectively calculates the hashCode of this instance object.
//      *
//      * @return the hashCode of this instance object.
//      */
//     @Override
//     public int hashCode() {
//         return HashCodeBuilder.reflectionHashCode(this);
//     }
// 
//     /**
//      * @return A human readable representation of this instance object and its fields.
//      */
//     @Override
//     public String toString() {
//         return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
//     }
// }
// 
// Path: src/main/java/io/github/tjheslin1/patterdale/config/RuntimeParameters.java
// public interface RuntimeParameters {
//     int httpPort();
//     long cacheDuration();
//     int probeConnectionWaitInSeconds();
//     List<DatabaseDefinition> databases();
//     List<Probe> probes();
//     int connectionPoolMaxSize();
//     int connectionPoolMinIdle();
//     int maxConnectionRetries();
//     long connectionRetryDelayInSeconds();
// }
// 
// Path: src/main/java/io/github/tjheslin1/patterdale/database/DBConnectionPool.java
// public interface DBConnectionPool {
//     DBConnection pool();
// }


import static java.lang.String.format;
import static java.util.Collections.emptyList;
import static java.util.concurrent.TimeUnit.SECONDS;
import io.github.tjheslin1.patterdale.ValueType;
import io.github.tjheslin1.patterdale.config.RuntimeParameters;
import io.github.tjheslin1.patterdale.database.DBConnectionPool;
import org.slf4j.Logger;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.TimeoutException;
/*
 * Copyright 2017 - 2021 Thomas Heslin <tjheslin1@kolabnow.com>.
 *
 * This file is part of Patterdale.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.github.tjheslin1.patterdale.metrics.probe;




/**
 * {@link OracleSQLProbe} implementation which expects the provided SQL to return one or more rows, with at least 2 columns.
 * The first column is expected to be a Double to be assigned as the metric value.
 * The second column and onwards represent the metric label values which will be filtered using `java.lang.String#format`
 * into the `metricLabels` provided in this probes' config.
 * <p>
 * If the probe fails or times out, an empty list of {@link ProbeResult} will be returned.
 */
public class ListOracleSQLProbe extends ValueType implements OracleSQLProbe {

    private static final int DYNAMIC_LABELS_START_INDEX = 2;

    private final Probe probe;
    private final Future<DBConnectionPool> connectionPool;
    private final RuntimeParameters runtimeParameters;
    private final Logger logger;

// Path: src/main/java/io/github/tjheslin1/patterdale/ValueType.java
// public abstract class ValueType {
// 
//     /**
//      * @param object The object to be compared to this instance.
//      * @return true if this instance matches the 'object'. Calculated reflectively on the fields.
//      */
//     @Override
//     public boolean equals(Object object) {
//         return EqualsBuilder.reflectionEquals(this, object);
//     }
// 
//     /**
//      * Reflectively calculates the hashCode of this instance object.
//      *
//      * @return the hashCode of this instance object.
//      */
//     @Override
//     public int hashCode() {
//         return HashCodeBuilder.reflectionHashCode(this);
//     }
// 
//     /**
//      * @return A human readable representation of this instance object and its fields.
//      */
//     @Override
//     public String toString() {
//         return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
//     }
// }
// 
// Path: src/main/java/io/github/tjheslin1/patterdale/config/RuntimeParameters.java
// public interface RuntimeParameters {
//     int httpPort();
//     long cacheDuration();
//     int probeConnectionWaitInSeconds();
//     List<DatabaseDefinition> databases();
//     List<Probe> probes();
//     int connectionPoolMaxSize();
//     int connectionPoolMinIdle();
//     int maxConnectionRetries();
//     long connectionRetryDelayInSeconds();
// }
// 
// Path: src/main/java/io/github/tjheslin1/patterdale/database/DBConnectionPool.java
// public interface DBConnectionPool {
//     DBConnection pool();
// }


// Path: src/main/java/io/github/tjheslin1/patterdale/metrics/probe/ListOracleSQLProbe.java
import static java.lang.String.format;
import static java.util.Collections.emptyList;
import static java.util.concurrent.TimeUnit.SECONDS;
import io.github.tjheslin1.patterdale.ValueType;
import io.github.tjheslin1.patterdale.config.RuntimeParameters;
import io.github.tjheslin1.patterdale.database.DBConnectionPool;
import org.slf4j.Logger;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.TimeoutException;

/*
 * Copyright 2017 - 2021 Thomas Heslin <tjheslin1@kolabnow.com>.
 *
 * This file is part of Patterdale.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.github.tjheslin1.patterdale.metrics.probe;




/**
 * {@link OracleSQLProbe} implementation which expects the provided SQL to return one or more rows, with at least 2 columns.
 * The first column is expected to be a Double to be assigned as the metric value.
 * The second column and onwards represent the metric label values which will be filtered using `java.lang.String#format`
 * into the `metricLabels` provided in this probes' config.
 * <p>
 * If the probe fails or times out, an empty list of {@link ProbeResult} will be returned.
 */
public class ListOracleSQLProbe extends ValueType implements OracleSQLProbe {

    private static final int DYNAMIC_LABELS_START_INDEX = 2;

    private final Probe probe;
    private final Future<DBConnectionPool> connectionPool;
    private final RuntimeParameters runtimeParameters;
    private final Logger logger;

    public ListOracleSQLProbe(Probe probe, Future<DBConnectionPool> connectionPool, RuntimeParameters runtimeParameters, Logger logger) {