Repository: kestra-io/kestra
File: jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcRepository.java (Java)

Code before:

            case ENDS_WITH -> DSL.field(columnName).like("%" + value);
            case CONTAINS -> DSL.field(columnName).like("%" + value + "%");
            case REGEX -> DSL.field(columnName).likeRegex((String) value);
            case PREFIX -> DSL.field(columnName).like(value + "%")
                    .or(DSL.field(columnName).eq(value));
            default -> throw new InvalidQueryFiltersException("Unsupported operation: " + operation);
        };
    }

    private static Object primitiveOrToString(Object o) {
        if (o == null) return null;

        if (o instanceof Boolean
            || o instanceof Byte
            || o instanceof Short
            || o instanceof Integer
            || o instanceof Long
            || o instanceof Float
            || o instanceof Double
            || o instanceof Character
            || o instanceof String) {
            return o;
        }

        return Objects.toString(o);
    }

    protected Name getColumnName(QueryFilter.Field field){
        return DSL.quotedName(field.name().toLowerCase());
    }

    protected Condition findQueryCondition(String query) {
        throw new InvalidQueryFiltersException("Unsupported operation: ");
    }

    protected Condition findLabelCondition(Either<Map<?, ?>, String> value, QueryFilter.Op operation) {
        throw new InvalidQueryFiltersException("Unsupported operation: " + operation);
    }

    // Generate the condition for Field.STATE
    @SuppressWarnings("unchecked")
    private Condition generateStateCondition(Object value, QueryFilter.Op operation) {
        List<State.Type> stateList = switch (value) {
            case List<?> list when !list.isEmpty() && list.getFirst() instanceof State.Type -> (List<State.Type>) list;
            case List<?> list -> list.stream().map(item -> State.Type.valueOf(item.toString())).toList();
            case State.Type state -> List.of(state);
            case String state -> List.of(State.Type.valueOf(state));
            default ->
                throw new InvalidQueryFiltersException("Field 'state' requires a State.Type or List<State.Type> value");
        };

Review comment (suggestion):
No need to something more complex as you already check for nullability.

```suggestion
        return o.toString();
```

Code after:

            case ENDS_WITH -> DSL.field(columnName).like("%" + value);
            case CONTAINS -> DSL.field(columnName).like("%" + value + "%");
            case REGEX -> DSL.field(columnName).likeRegex((String) value);
            case PREFIX -> DSL.field(columnName).like(value + "%")
                    .or(DSL.field(columnName).eq(value));
            default -> throw new InvalidQueryFiltersException("Unsupported operation: " + operation);
        };
    }

    private static Object primitiveOrToString(Object o) {
        if (o == null) return null;

        if (o instanceof Boolean
            || o instanceof Byte
            || o instanceof Short
            || o instanceof Integer
            || o instanceof Long
            || o instanceof Float
            || o instanceof Double
            || o instanceof Character
            || o instanceof String) {
            return o;
        }

        return o.toString();
    }

    protected Name getColumnName(QueryFilter.Field field){
        return DSL.quotedName(field.name().toLowerCase());
    }

    protected Condition findQueryCondition(String query) {
        throw new InvalidQueryFiltersException("Unsupported operation: ");
    }

    protected Condition findLabelCondition(Either<Map<?, ?>, String> value, QueryFilter.Op operation) {
        throw new InvalidQueryFiltersException("Unsupported operation: " + operation);
    }

    // Generate the condition for Field.STATE
    @SuppressWarnings("unchecked")
    private Condition generateStateCondition(Object value, QueryFilter.Op operation) {
        List<State.Type> stateList = switch (value) {
            case List<?> list when !list.isEmpty() && list.getFirst() instanceof State.Type -> (List<State.Type>) list;
            case List<?> list -> list.stream().map(item -> State.Type.valueOf(item.toString())).toList();
            case State.Type state -> List.of(state);
            case String state -> List.of(State.Type.valueOf(state));
            default ->
                throw new InvalidQueryFiltersException("Field 'state' requires a State.Type or List<State.Type> value");
        };