class CompoundQuery implements Query<O> {

    public static <O> CompoundQuery<O> fromAndQueryIfSuitable(And<O> andQuery) {
        if (andQuery.hasLogicalQueries() || andQuery.hasComparativeQueries()) {
            return null;
        }
        List<Attribute<O, ?>> attributeList = new ArrayList<Attribute<O, ?>>(andQuery.getSimpleQueries().size());
        for (SimpleQuery<O, ?> simpleQuery : andQuery.getSimpleQueries()) {
            if (!(simpleQuery instanceof Equal)) {
                return null;
            }
            attributeList.add(simpleQuery.getAttribute());
        }
        CompoundAttribute<O> compoundAttribute = new CompoundAttribute<O>(attributeList);

        return new CompoundQuery<O>(andQuery, compoundAttribute);
    }

    public  CompoundQuery(And<O> andQuery, CompoundAttribute<O> compoundAttribute);

}