All Downloads are FREE. Search and download functionalities are using the official Maven repository.

info.archinnov.achilles.generated.function.FunctionsRegistry Maven / Gradle / Ivy

There is a newer version: 6.1.0
Show newest version
package info.archinnov.achilles.generated.function;

import com.datastax.driver.core.querybuilder.QueryBuilder;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * This class is the common registry for all registered user-defined functions */
public final class FunctionsRegistry {
  /**
   * Call "textToLong" function with given parameters */
  public static final Long_Type textToLong(final String_Type longValue) {
    final List params = new ArrayList<>();
    if (longValue.isFunctionCall()) {
      params.add(longValue.buildRecursive());
    } else {
      params.add(longValue.hasLiteralValue() ? longValue.getValue() : QueryBuilder.column((String)longValue.getValue()));
    }
    return new Long_Type(Optional.empty()) {
      @Override
      public boolean isFunctionCall() {
        return true;
      }

      @Override
      public String functionName() {
        return "textToLong";
      }

      @Override
      public List parameters() {
        return params;
      }
    };
  }

  /**
   * Call "accumulate" function with given parameters */
  public static final Map_Integer_String_Type accumulate(final Map_Integer_String_Type map, final Integer_Type clustering, final String_Type stringVal, final Double_Type doubleVal, final Double_Type lowThreshold, final Double_Type highThreshold) {
    final List params = new ArrayList<>();
    if (map.isFunctionCall()) {
      params.add(map.buildRecursive());
    } else {
      params.add(map.hasLiteralValue() ? map.getValue() : QueryBuilder.column((String)map.getValue()));
    }
    if (clustering.isFunctionCall()) {
      params.add(clustering.buildRecursive());
    } else {
      params.add(clustering.hasLiteralValue() ? clustering.getValue() : QueryBuilder.column((String)clustering.getValue()));
    }
    if (stringVal.isFunctionCall()) {
      params.add(stringVal.buildRecursive());
    } else {
      params.add(stringVal.hasLiteralValue() ? stringVal.getValue() : QueryBuilder.column((String)stringVal.getValue()));
    }
    if (doubleVal.isFunctionCall()) {
      params.add(doubleVal.buildRecursive());
    } else {
      params.add(doubleVal.hasLiteralValue() ? doubleVal.getValue() : QueryBuilder.column((String)doubleVal.getValue()));
    }
    if (lowThreshold.isFunctionCall()) {
      params.add(lowThreshold.buildRecursive());
    } else {
      params.add(lowThreshold.hasLiteralValue() ? lowThreshold.getValue() : QueryBuilder.column((String)lowThreshold.getValue()));
    }
    if (highThreshold.isFunctionCall()) {
      params.add(highThreshold.buildRecursive());
    } else {
      params.add(highThreshold.hasLiteralValue() ? highThreshold.getValue() : QueryBuilder.column((String)highThreshold.getValue()));
    }
    return new Map_Integer_String_Type(Optional.empty()) {
      @Override
      public boolean isFunctionCall() {
        return true;
      }

      @Override
      public String functionName() {
        return "accumulate";
      }

      @Override
      public List parameters() {
        return params;
      }
    };
  }

  /**
   * Call "findByDoubleValue" function with given parameters */
  public static final Map_Integer_String_Type findByDoubleValue(final Integer_Type clustering, final String_Type stringVal, final Double_Type doubleVal, final Double_Type lowThreshold, final Double_Type highThreshold) {
    final List params = new ArrayList<>();
    if (clustering.isFunctionCall()) {
      params.add(clustering.buildRecursive());
    } else {
      params.add(clustering.hasLiteralValue() ? clustering.getValue() : QueryBuilder.column((String)clustering.getValue()));
    }
    if (stringVal.isFunctionCall()) {
      params.add(stringVal.buildRecursive());
    } else {
      params.add(stringVal.hasLiteralValue() ? stringVal.getValue() : QueryBuilder.column((String)stringVal.getValue()));
    }
    if (doubleVal.isFunctionCall()) {
      params.add(doubleVal.buildRecursive());
    } else {
      params.add(doubleVal.hasLiteralValue() ? doubleVal.getValue() : QueryBuilder.column((String)doubleVal.getValue()));
    }
    if (lowThreshold.isFunctionCall()) {
      params.add(lowThreshold.buildRecursive());
    } else {
      params.add(lowThreshold.hasLiteralValue() ? lowThreshold.getValue() : QueryBuilder.column((String)lowThreshold.getValue()));
    }
    if (highThreshold.isFunctionCall()) {
      params.add(highThreshold.buildRecursive());
    } else {
      params.add(highThreshold.hasLiteralValue() ? highThreshold.getValue() : QueryBuilder.column((String)highThreshold.getValue()));
    }
    return new Map_Integer_String_Type(Optional.empty()) {
      @Override
      public boolean isFunctionCall() {
        return true;
      }

      @Override
      public String functionName() {
        return "findByDoubleValue";
      }

      @Override
      public List parameters() {
        return params;
      }
    };
  }
}