Added toString methods to make debugging easier.

This commit is contained in:
Oliver Gierke
2011-03-02 11:14:50 +01:00
parent cae2961275
commit 3a6113c5e8
3 changed files with 50 additions and 0 deletions

View File

@@ -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
*/

View File

@@ -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)
*

View File

@@ -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 {