class Constraints implements Iterable<Constraint> {

    public static Constraints parse(String input) {
        if (emptyToNull(input) != null) {
            Operator operator;
            if (input.contains(AND.operator)) {
                operator = AND;
            } else if (input.contains(OR.operator)) {
                operator = OR;
            } else {
                operator = AND;
            }
            Iterable<String> values = Splitter.on(operator.operator)
                    .omitEmptyStrings()
                    .trimResults()
                    .split(input);
            LinkedHashSet<Constraint> constraints = new LinkedHashSet<>();
            for (String value : values) {
                try {
                    constraints.add(Constraint.parse(value));
                } catch (IllegalArgumentException ignored) {
                }
            }
            return new Constraints(constraints, operator);

        } else {
            return empty();
        }
    }

    private  Constraints(LinkedHashSet<Constraint> constraints, Operator operator);

}