PandaLib/src/fr/pandacube/java/util/db2/sql_tools/SQLWhereNull.java
Marc Baloup b2a19e09c1 Mise à jour ORM + Utilisation plus simple des logs
- toute la base de données fonctionne en utf8mb4
- Le PlayerFinder gère l'historique des pseudos
- Fin de l'utilisation de l'ancien ORM
2016-12-28 05:08:00 +01:00

38 lines
1.1 KiB
Java

package fr.pandacube.java.util.db2.sql_tools;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import fr.pandacube.java.util.Log;
import javafx.util.Pair;
public class SQLWhereNull extends SQLWhere {
private SQLField<?> fild;
private boolean nulll;
/**
* Init a IS NULL / IS NOT NULL expression for a SQL WHERE condition.
* @param field the field to check null / not null state
* @param isNull true if we want to ckeck if "IS NULL", or false to check if "IS NOT NULL"
*/
public SQLWhereNull(SQLField<?> field, boolean isNull) {
if (field == null)
throw new IllegalArgumentException("field can't be null");
if (!field.canBeNull)
Log.getLogger().log(Level.WARNING, "Useless : Trying to check IS [NOT] NULL on the field "+field.getSQLElementType().getName()+"#"+field.name+" which is declared in the ORM as 'can't be null'");
fild = field;
nulll = isNull;
}
@Override
public Pair<String, List<Object>> toSQL() {
return new Pair<>(fild.name + " IS" + ((nulll)?" NULL":" NOT NULL"), new ArrayList<>());
}
}