Skip to content

Commit

Permalink
Criteria. Change poorly named inner class Start to Self (which is mor…
Browse files Browse the repository at this point in the history
…e desriptive)
  • Loading branch information
asereda-gs committed Apr 13, 2019
1 parent db5439c commit 43f8a3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Expand Up @@ -15,7 +15,7 @@ public class ReflectionTest {
@Test @Test
public void reflection() { public void reflection() {
// TODO this inner class is ugly // TODO this inner class is ugly
final PersonCriteria.Start crit = PersonCriteria.create(); final PersonCriteria.Self crit = PersonCriteria.create();


final ImmutablePerson person = ImmutablePerson.builder().firstName("John").age(22) final ImmutablePerson person = ImmutablePerson.builder().firstName("John").age(22)
.bestFriend(ImmutableFriend.builder().nickName("aaa").build()) .bestFriend(ImmutableFriend.builder().nickName("aaa").build())
Expand Down Expand Up @@ -74,7 +74,7 @@ public void collection() {


@Test @Test
public void debug() { public void debug() {
PersonCriteria<PersonCriteria.Start> crit = PersonCriteria.create() PersonCriteria<PersonCriteria.Self> crit = PersonCriteria.create()
.lastName.isAbsent() .lastName.isAbsent()
.bestFriend.nickName.isNotEmpty() .bestFriend.nickName.isNotEmpty()
.or().or() // yuck :( .or().or() // yuck :(
Expand Down
Expand Up @@ -87,18 +87,18 @@ DocumentCriteria<R>, ValueCriteria<R, [type.name]>, Disjunction<R>, Expressional
[/for] [/for]


/** TODO this should be top-level class */ /** TODO this should be top-level class */
public static final class Start extends [type.name]Criteria<Start> { public static final class Self extends [type.name]Criteria<Self> {


private Start() { private Self() {
this(new CriteriaContext<Start>(creator())); this(new CriteriaContext<Self>(creator()));
} }


private Start(CriteriaContext<Start> context) { private Self(CriteriaContext<Self> context) {
super(context); super(context);
} }


private static CriteriaCreator<Start> creator() { private static CriteriaCreator<Self> creator() {
return (CriteriaContext<Start> ctx) -> new Start(ctx); return (CriteriaContext<Self> ctx) -> new Self(ctx);
} }
} }


Expand All @@ -115,8 +115,8 @@ DocumentCriteria<R>, ValueCriteria<R, [type.name]>, Disjunction<R>, Expressional
return context.or().create(); return context.or().create();
} }


public static Start create() { public static Self create() {
return new Start(); return new Self();
} }


@Override @Override
Expand All @@ -137,15 +137,15 @@ StringCriteria<R>
[if a.hasSimpleScalarElementType] [if a.hasSimpleScalarElementType]
OptionalCriteria<R, [a.wrappedElementType], [scalarElementCriteria a 'R'], [scalarElementCriteria a '?']> OptionalCriteria<R, [a.wrappedElementType], [scalarElementCriteria a 'R'], [scalarElementCriteria a '?']>
[else if a.hasCriteria] [else if a.hasCriteria]
OptionalCriteria<R, [a.wrappedElementType], [a.unwrappedElementType]Criteria<R>, [a.unwrappedElementType]Criteria.Start> OptionalCriteria<R, [a.wrappedElementType], [a.unwrappedElementType]Criteria<R>, [a.unwrappedElementType]Criteria.Self>
[/if] [/if]
[else if a.comparable] [else if a.comparable]
ComparableCriteria<R, [a.wrappedElementType]> ComparableCriteria<R, [a.wrappedElementType]>
[else if a.collectionType] [else if a.collectionType]
[if a.hasSimpleScalarElementType] [if a.hasSimpleScalarElementType]
CollectionCriteria<R, [a.wrappedElementType], [scalarElementCriteria a 'R'], [scalarElementCriteria a '?']> CollectionCriteria<R, [a.wrappedElementType], [scalarElementCriteria a 'R'], [scalarElementCriteria a '?']>
[else if a.hasCriteria] [else if a.hasCriteria]
CollectionCriteria<R, [a.wrappedElementType], [a.unwrappedElementType]Criteria<R>, [a.unwrappedElementType]Criteria.Start> CollectionCriteria<R, [a.wrappedElementType], [a.unwrappedElementType]Criteria<R>, [a.unwrappedElementType]Criteria.Self>
[else] [else]
[output.error]Can't create criteria for collection [a.name] [a.unwrappedElementType][/output.error] [output.error]Can't create criteria for collection [a.name] [a.unwrappedElementType][/output.error]
[/if] [/if]
Expand Down

0 comments on commit 43f8a3b

Please sign in to comment.