package com.gxwebsoft.house.ai;

import com.gxwebsoft.house.entity.HouseInfo;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * AI找房搜索结果。
 */
@Data
public class HouseAiSearchResult {

    private String matchType = HouseAiMatchTypes.NONE;

    private List<HouseInfo> houses = new ArrayList<>();

    public static HouseAiSearchResult exact(List<HouseInfo> houses) {
        return of(HouseAiMatchTypes.EXACT, houses);
    }

    public static HouseAiSearchResult approximate(List<HouseInfo> houses) {
        return of(HouseAiMatchTypes.APPROXIMATE, houses);
    }

    public static HouseAiSearchResult none() {
        return of(HouseAiMatchTypes.NONE, new ArrayList<>());
    }

    public boolean hasHouses() {
        return houses != null && !houses.isEmpty();
    }

    private static HouseAiSearchResult of(String matchType, List<HouseInfo> houses) {
        HouseAiSearchResult result = new HouseAiSearchResult();
        result.setMatchType(matchType);
        result.setHouses(houses == null ? new ArrayList<>() : houses);
        return result;
    }
}
