Added toString methods to make debugging easier.
This commit is contained in:
@@ -113,6 +113,18 @@ public class Part {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return String.format("%s %s", property.getName(), type);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.regex.Pattern;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.repository.query.parser.PartTree.OrPart;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
||||
/**
|
||||
@@ -179,6 +180,20 @@ public class PartTree implements Iterable<OrPart> {
|
||||
return group != null && group.contains(DISTINCT);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return String.format("%s %s",
|
||||
StringUtils.collectionToDelimitedString(nodes, " or "),
|
||||
orderBySource.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* A part of the parsed source that results from splitting up the resource
|
||||
* ar {@literal Or} keywords. Consists of {@link Part}s that have to be
|
||||
@@ -209,6 +224,18 @@ public class PartTree implements Iterable<OrPart> {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return StringUtils.collectionToDelimitedString(children, " and ");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -82,6 +82,17 @@ public class PartTreeUnitTests {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void parsesCombinedAndAndOrPropertiesCorrectly() throws Exception {
|
||||
|
||||
PartTree tree =
|
||||
new PartTree("firstnameAndLastnameOrLastname", User.class);
|
||||
assertPart(tree, new Part[] { new Part("firstname", User.class),
|
||||
new Part("lastname", User.class) }, new Part[] { new Part(
|
||||
"lastname", User.class) });
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void hasSortIfOrderByIsGiven() throws Exception {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user