package ai.decompile.workspace.model.specification;

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

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

  public static Specification<Project> hasWorkspaceId(UUID workspaceId) {
    return (root, _, cb) -> cb.equal(root.get("workspace").get("id"), workspaceId);
  }
}
