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