-
Notifications
You must be signed in to change notification settings - Fork 44
Fixes #105, addressing comments for #106 #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,5 @@ | |
| *.jar | ||
| *.war | ||
| *.ear | ||
| /Vagrantfile | ||
| /.vagrant/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,13 +12,16 @@ | |
| */ | ||
| package org.assertj.assertions.generator.description; | ||
|
|
||
| import com.google.common.reflect.TypeToken; | ||
| import org.assertj.assertions.generator.util.ClassUtil; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.Objects; | ||
| import java.util.Set; | ||
| import java.util.TreeSet; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import com.google.common.reflect.TypeToken; | ||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.assertj.assertions.generator.util.ClassUtil; | ||
|
|
||
| /** | ||
| * | ||
|
|
@@ -102,6 +105,38 @@ public void addDeclaredFieldDescriptions(Set<FieldDescription> declaredFieldDesc | |
| this.declaredFieldsDescriptions.addAll(declaredFieldDescriptions); | ||
| } | ||
|
|
||
| Stream<GetterDescription> getGetterStreamForField(FieldDescription base) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing java 7 only 😿 will be java 8 for 3.0
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably add the restriction to Maven. I forgot and IntelliJ let me do it, so I just went with it. :(
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm integrating this PR and reworking it to use java 7
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Damn, I forgot about this -- I'm sorry. |
||
| final String capName = StringUtils.capitalize(base.getName()); | ||
|
|
||
| Stream<GetterDescription> getterStream = | ||
| Stream.concat(this.gettersDescriptions.stream(), | ||
| this.declaredGettersDescriptions.stream()) | ||
| .distinct() | ||
| .filter(getter -> Objects.equals(base.getValueType(), getter.getValueType())); | ||
|
|
||
| if (ClassUtil.isBoolean(base.getValueType())) { | ||
| // deal with predicates by building a set of all of the valid predicates available | ||
| Set<String> validNames = ClassUtil.PREDICATE_PREFIXES.keySet() | ||
| .stream() | ||
| .map(prefix -> prefix + capName) | ||
| .collect(Collectors.toSet()); | ||
|
|
||
| return getterStream.filter(getter -> validNames.contains(getter.getOriginalMember().getName())); | ||
| } | ||
|
|
||
| final String propName = "get" + capName; | ||
|
|
||
| return getterStream.filter(getter -> Objects.equals(getter.getOriginalMember().getName(), propName)); | ||
| } | ||
|
|
||
| public boolean hasGetterForField(FieldDescription base) { | ||
| return getGetterStreamForField(base).findAny().isPresent(); | ||
| } | ||
|
|
||
| public Set<GetterDescription> findGettersForField(FieldDescription base) { | ||
| return getGetterStreamForField(base).collect(Collectors.toCollection(TreeSet::new)); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "ClassDescription [valueType=" + type + "]"; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry still on java 7 !