From 6c32b479d3f71f4f7a3961ef490ff1c75e1f7f0f Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Mon, 21 May 2012 14:15:00 +0200 Subject: [PATCH] DATACMNS-174 - Part.Type now exposes keywords. --- .../data/repository/query/parser/Part.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/repository/query/parser/Part.java b/spring-data-commons-core/src/main/java/org/springframework/data/repository/query/parser/Part.java index d3f67db5f..8a9727353 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/repository/query/parser/Part.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/repository/query/parser/Part.java @@ -15,7 +15,10 @@ */ package org.springframework.data.repository.query.parser; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -188,6 +191,16 @@ public class Part { GREATER_THAN, GREATER_THAN_EQUAL, BEFORE, AFTER, NOT_LIKE, LIKE, STARTING_WITH, ENDING_WITH, CONTAINING, NOT_IN, IN, NEAR, WITHIN, REGEX, EXISTS, TRUE, FALSE, NEGATING_SIMPLE_PROPERTY, SIMPLE_PROPERTY); + public static final Collection ALL_KEYWORDS; + + static { + List allKeywords = new ArrayList(); + for (Type type : ALL) { + allKeywords.addAll(type.keywords); + } + ALL_KEYWORDS = Collections.unmodifiableList(allKeywords); + } + private final List keywords; private final int numberOfArguments; @@ -228,6 +241,15 @@ public class Part { return SIMPLE_PROPERTY; } + /** + * Returns all keywords supported by the current {@link Type}. + * + * @return + */ + public Collection getKeywords() { + return Collections.unmodifiableList(keywords); + } + /** * Returns whether the the type supports the given raw propertyPath. Default implementation checks whether the * propertyPath ends with the registered keyword. Does not support the keyword if the propertyPath is a valid field