org.springframework.data.repository.query.parser.Part有什么用?

What's the usage of org.springframework.data.repository.query.parser.Part?

正如您在标题中看到的,如果有人能告诉我 Class 的用法,我将不胜感激。

里面有个枚举类型,怎么用?

public static enum Type {

        BETWEEN(2, "IsBetween", "Between"), IS_NOT_NULL(0, "IsNotNull", "NotNull"), IS_NULL(0, "IsNull", "Null"), LESS_THAN(
                "IsLessThan", "LessThan"), LESS_THAN_EQUAL("IsLessThanEqual", "LessThanEqual"), GREATER_THAN("IsGreaterThan",
                "GreaterThan"), GREATER_THAN_EQUAL("IsGreaterThanEqual", "GreaterThanEqual"), BEFORE("IsBefore", "Before"), AFTER(
                "IsAfter", "After"), NOT_LIKE("IsNotLike", "NotLike"), LIKE("IsLike", "Like"), STARTING_WITH("IsStartingWith",
                "StartingWith", "StartsWith"), ENDING_WITH("IsEndingWith", "EndingWith", "EndsWith"), NOT_CONTAINING(
                "IsNotContaining", "NotContaining", "NotContains"), CONTAINING("IsContaining", "Containing", "Contains"), NOT_IN(
                "IsNotIn", "NotIn"), IN("IsIn", "In"), NEAR("IsNear", "Near"), WITHIN("IsWithin", "Within"), REGEX(
                "MatchesRegex", "Matches", "Regex"), EXISTS(0, "Exists"), TRUE(0, "IsTrue", "True"), FALSE(0, "IsFalse",
                "False"), NEGATING_SIMPLE_PROPERTY("IsNot", "Not"), SIMPLE_PROPERTY("Is", "Equals");

        // Need to list them again explicitly as the order is important
        // (esp. for IS_NULL, IS_NOT_NULL)
        private static final List<Part.Type> ALL = Arrays.asList(IS_NOT_NULL, IS_NULL, BETWEEN, LESS_THAN, LESS_THAN_EQUAL,
                GREATER_THAN, GREATER_THAN_EQUAL, BEFORE, AFTER, NOT_LIKE, LIKE, STARTING_WITH, ENDING_WITH, NOT_CONTAINING,
                CONTAINING, NOT_IN, IN, NEAR, WITHIN, REGEX, EXISTS, TRUE, FALSE, NEGATING_SIMPLE_PROPERTY, SIMPLE_PROPERTY);
...}

Part 是 Spring 数据的内部。它不打算由客户端代码使用。因此,如果您不实现自己的 Spring 数据模块,则根本不应该使用它,也不应该使用其中的任何内容。

Part 基本上是 AST 的一个元素,它可能会导致 where 子句或等效项的元素,具体取决于所使用的存储。

例如如果你有一个方法 findByNameAndDobBetween(String, Date, Date) 解析方法名称将导致两部分。一种用于 name 条件,另一种用于 DOB between 条件。

类型枚举列出了所有可能的不同类型的条件。 元素的参数是所需的方法参数的数量和(可能是多个)在方法名称中标识此类型的 Strings。