// Path: src/main/java/org/v8LogScanner/dbLayer/genericRepository/DataRepository.java
// public interface DataRepository<T> {
// 
//     public Serializable add(T object);
// 
//     public void remove(T object);
// 
//     public void update(T object);
// 
//     public void resetCache();
// 
//     public List<T> query(QuerySpecification<T> specification);
// 
// }
// 
// Path: src/main/java/org/v8LogScanner/dbLayer/genericRepository/QuerySpecification.java
// public interface QuerySpecification<T> {
// 
//     boolean specified(T object);
// 
//     public CriteriaQuery<T> toCriteria(CriteriaBuilder builder);
// 
// }
// 
// Path: src/main/java/org/v8LogScanner/dbLayer/genericRepository/ScanProfileService.java
// public interface ScanProfileService {
// 
//     public int add(ScanProfile profile);
// 
//     public void remove(ScanProfile profile);
// 
//     public void update(ScanProfile profile);
// 
//     public void resetCache();
// 
//     public ScanProfile find(ScanProfile profile);
// 
//     public ScanProfile find(int id);
// 
//     public ScanProfile findIfPresent();
// 
//     public List<ScanProfile> getAll();
// 
// }
// 
// Path: src/main/java/org/v8LogScanner/dbLayer/scanProfilesPersistence/Specifications/ScanProfileHibSpecByID.java
// public class ScanProfileHibSpecByID implements QuerySpecification<ScanProfileHib> {
// 
//     private int id;
// 
//     public ScanProfileHibSpecByID(int id) {
//         this.id = id;
//     }
// 
//     @Override
//     public boolean specified(ScanProfileHib profile) {
//         return id == profile.getId();
//     }
// 
//     public CriteriaQuery<ScanProfileHib> toCriteria(CriteriaBuilder builder) {
// 
//         CriteriaQuery<ScanProfileHib> criteria = builder.createQuery(ScanProfileHib.class);
//         Root<ScanProfileHib> root = criteria.from(ScanProfileHib.class);
// 
//         criteria.where(builder.equal(root.get("id"), id));
//         criteria.select(root);
// 
//         return criteria;
//     }
// }
// 
// Path: src/main/java/org/v8LogScanner/dbLayer/scanProfilesPersistence/Specifications/ScanProfileHibSpecByName.java
// public class ScanProfileHibSpecByName implements QuerySpecification<ScanProfileHib> {
// 
//     private String name;
// 
//     public ScanProfileHibSpecByName(String name) {
//         this.name = name;
//     }
// 
//     @Override
//     public boolean specified(ScanProfileHib profile) {
//         return name == profile.getName();
//     }
// 
//     public CriteriaQuery<ScanProfileHib> toCriteria(CriteriaBuilder builder) {
// 
//         CriteriaQuery<ScanProfileHib> criteria = builder.createQuery(ScanProfileHib.class);
//         Root<ScanProfileHib> root = criteria.from(ScanProfileHib.class);
// 
//         criteria.where(builder.equal(root.get("name"), name));
//         criteria.select(root);
// 
//         return criteria;
//     }
// }
// 
// Path: src/main/java/org/v8LogScanner/dbLayer/scanProfilesPersistence/Specifications/ScanProfileHibSpecIfPresent.java
// public class ScanProfileHibSpecIfPresent implements QuerySpecification<ScanProfileHib> {
// 
//     @Override
//     public boolean specified(ScanProfileHib profile) {
//         return profile.getId() >= 0;
//     }
// 
//     public CriteriaQuery<ScanProfileHib> toCriteria(CriteriaBuilder builder) {
// 
//         CriteriaQuery<ScanProfileHib> criteria = builder.createQuery(ScanProfileHib.class);
// 
//         Root<ScanProfileHib> root = criteria.from(ScanProfileHib.class);
//         criteria.select(root).from(ScanProfileHib.class);
//         criteria.orderBy(builder.desc(root.get("id")));
// 
//         return criteria;
//     }
// }


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.v8LogScanner.dbLayer.genericRepository.DataRepository;
import org.v8LogScanner.dbLayer.genericRepository.QuerySpecification;
import org.v8LogScanner.dbLayer.genericRepository.ScanProfileService;
import org.v8LogScanner.dbLayer.scanProfilesPersistence.Specifications.ScanProfileHibSpecByID;
import org.v8LogScanner.dbLayer.scanProfilesPersistence.Specifications.ScanProfileHibSpecByName;
import org.v8LogScanner.dbLayer.scanProfilesPersistence.Specifications.ScanProfileHibSpecIfPresent;
import org.v8LogScanner.rgx.ScanProfile;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
    }

    @Override
    public ScanProfile find(ScanProfile profile) {

        QuerySpecification<ScanProfileHib> spec = new ScanProfileHibSpecByName(profile.getName());
        List<ScanProfileHib> profiles = repository.query(spec);
        if (profiles.size() > 0) {
            ScanProfile prof = profiles.get(0);
            return prof;
        }
        else
            return null;
    }

    @Override
    public ScanProfile find(int id) {
        QuerySpecification<ScanProfileHib> spec = new ScanProfileHibSpecByID(id);
        List<ScanProfileHib> profiles = repository.query(spec);
        if (profiles.size() > 0)
            return (ScanProfile) profiles.get(0);
        else
            return null;
    }

    @Override
    public ScanProfile findIfPresent() {

        ScanProfile profile = null;

// Path: src/main/java/org/v8LogScanner/dbLayer/genericRepository/DataRepository.java
// public interface DataRepository<T> {
// 
//     public Serializable add(T object);
// 
//     public void remove(T object);
// 
//     public void update(T object);
// 
//     public void resetCache();
// 
//     public List<T> query(QuerySpecification<T> specification);
// 
// }
// 
// Path: src/main/java/org/v8LogScanner/dbLayer/genericRepository/QuerySpecification.java
// public interface QuerySpecification<T> {
// 
//     boolean specified(T object);
// 
//     public CriteriaQuery<T> toCriteria(CriteriaBuilder builder);
// 
// }
// 
// Path: src/main/java/org/v8LogScanner/dbLayer/genericRepository/ScanProfileService.java
// public interface ScanProfileService {
// 
//     public int add(ScanProfile profile);
// 
//     public void remove(ScanProfile profile);
// 
//     public void update(ScanProfile profile);
// 
//     public void resetCache();
// 
//     public ScanProfile find(ScanProfile profile);
// 
//     public ScanProfile find(int id);
// 
//     public ScanProfile findIfPresent();
// 
//     public List<ScanProfile> getAll();
// 
// }
// 
// Path: src/main/java/org/v8LogScanner/dbLayer/scanProfilesPersistence/Specifications/ScanProfileHibSpecByID.java
// public class ScanProfileHibSpecByID implements QuerySpecification<ScanProfileHib> {
// 
//     private int id;
// 
//     public ScanProfileHibSpecByID(int id) {
//         this.id = id;
//     }
// 
//     @Override
//     public boolean specified(ScanProfileHib profile) {
//         return id == profile.getId();
//     }
// 
//     public CriteriaQuery<ScanProfileHib> toCriteria(CriteriaBuilder builder) {
// 
//         CriteriaQuery<ScanProfileHib> criteria = builder.createQuery(ScanProfileHib.class);
//         Root<ScanProfileHib> root = criteria.from(ScanProfileHib.class);
// 
//         criteria.where(builder.equal(root.get("id"), id));
//         criteria.select(root);
// 
//         return criteria;
//     }
// }
// 
// Path: src/main/java/org/v8LogScanner/dbLayer/scanProfilesPersistence/Specifications/ScanProfileHibSpecByName.java
// public class ScanProfileHibSpecByName implements QuerySpecification<ScanProfileHib> {
// 
//     private String name;
// 
//     public ScanProfileHibSpecByName(String name) {
//         this.name = name;
//     }
// 
//     @Override
//     public boolean specified(ScanProfileHib profile) {
//         return name == profile.getName();
//     }
// 
//     public CriteriaQuery<ScanProfileHib> toCriteria(CriteriaBuilder builder) {
// 
//         CriteriaQuery<ScanProfileHib> criteria = builder.createQuery(ScanProfileHib.class);
//         Root<ScanProfileHib> root = criteria.from(ScanProfileHib.class);
// 
//         criteria.where(builder.equal(root.get("name"), name));
//         criteria.select(root);
// 
//         return criteria;
//     }
// }
// 
// Path: src/main/java/org/v8LogScanner/dbLayer/scanProfilesPersistence/Specifications/ScanProfileHibSpecIfPresent.java
// public class ScanProfileHibSpecIfPresent implements QuerySpecification<ScanProfileHib> {
// 
//     @Override
//     public boolean specified(ScanProfileHib profile) {
//         return profile.getId() >= 0;
//     }
// 
//     public CriteriaQuery<ScanProfileHib> toCriteria(CriteriaBuilder builder) {
// 
//         CriteriaQuery<ScanProfileHib> criteria = builder.createQuery(ScanProfileHib.class);
// 
//         Root<ScanProfileHib> root = criteria.from(ScanProfileHib.class);
//         criteria.select(root).from(ScanProfileHib.class);
//         criteria.orderBy(builder.desc(root.get("id")));
// 
//         return criteria;
//     }
// }


// Path: src/main/java/org/v8LogScanner/dbLayer/scanProfilesPersistence/ScanProfileHibService.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.v8LogScanner.dbLayer.genericRepository.DataRepository;
import org.v8LogScanner.dbLayer.genericRepository.QuerySpecification;
import org.v8LogScanner.dbLayer.genericRepository.ScanProfileService;
import org.v8LogScanner.dbLayer.scanProfilesPersistence.Specifications.ScanProfileHibSpecByID;
import org.v8LogScanner.dbLayer.scanProfilesPersistence.Specifications.ScanProfileHibSpecByName;
import org.v8LogScanner.dbLayer.scanProfilesPersistence.Specifications.ScanProfileHibSpecIfPresent;
import org.v8LogScanner.rgx.ScanProfile;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

    }

    @Override
    public ScanProfile find(ScanProfile profile) {

        QuerySpecification<ScanProfileHib> spec = new ScanProfileHibSpecByName(profile.getName());
        List<ScanProfileHib> profiles = repository.query(spec);
        if (profiles.size() > 0) {
            ScanProfile prof = profiles.get(0);
            return prof;
        }
        else
            return null;
    }

    @Override
    public ScanProfile find(int id) {
        QuerySpecification<ScanProfileHib> spec = new ScanProfileHibSpecByID(id);
        List<ScanProfileHib> profiles = repository.query(spec);
        if (profiles.size() > 0)
            return (ScanProfile) profiles.get(0);
        else
            return null;
    }

    @Override
    public ScanProfile findIfPresent() {

        ScanProfile profile = null;

        QuerySpecification<ScanProfileHib> spec = new ScanProfileHibSpecIfPresent();