瀏覽代碼

Ajout méthode recherche sur le libelle

Arthur Brandao 5 年之前
父節點
當前提交
1da6b36a3b
共有 1 個文件被更改,包括 19 次插入0 次删除
  1. 19 0
      src/db/table/EspaceTable.java

+ 19 - 0
src/db/table/EspaceTable.java

@@ -1,5 +1,8 @@
 package db.table;
 
+import java.util.List;
+import java.util.Optional;
+
 import db.Table;
 import db.annotation.DbTable;
 import entity.Espace;
@@ -13,6 +16,22 @@ public class EspaceTable extends Table<Espace>{
 		// Private constructor for singleton
 	}
 	
+	public Espace getByLibelle(String lib) {
+		List<Espace> list = getByField("LIBELLE", lib);
+		if(list.isEmpty()) {
+			return null;
+		}
+		return list.get(0);
+	}
+	
+	public Optional<Espace> findByLibelle(String lib) {
+		Espace e = getByLibelle(lib);
+		if (e == null) {
+			return Optional.empty();
+		}
+		return Optional.of(e);
+	}
+	
 	public static EspaceTable getInstance() {
 		if(instance == null) {
 			instance = new EspaceTable();