package ai.decompile.workspace.model.specification;

import ai.decompile.workspace.model.entity.Binary;
import java.util.UUID;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.springframework.data.jpa.domain.Specification;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class BinarySpecification {
  public static Specification<Binary> filenameContains(String filename) {
    return (root, _, cb) ->
        cb.like(cb.lower(root.get("filename")), "%" + filename.toLowerCase() + "%");
  }

  public static Specification<Binary> hasProjectId(UUID projectId) {
    return (root, _, cb) -> cb.equal(root.get("project").get("id"), projectId);
  }
}
