Skip to content

Commit

Permalink
make attributes with wilcard always regular. Fixes #73
Browse files Browse the repository at this point in the history
  • Loading branch information
elucash committed Jan 8, 2015
1 parent 793aab8 commit 4b21841
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Expand Up @@ -93,8 +93,7 @@ public final boolean process(Set<? extends TypeElement> annotations, RoundEnviro
} catch (Exception ex) {
processingEnv.getMessager()
.printMessage(Diagnostic.Kind.ERROR,
Joiner.on('\n').join(
AbstractGenerator.class.getName() + " threw", Throwables.getStackTraceAsString(ex)));
Joiner.on('\n').join(getClass().getName() + " threw", Throwables.getStackTraceAsString(ex)));
}
return false;
}
Expand Down
Expand Up @@ -747,8 +747,23 @@ boolean isIdAttribute() {
return getMarshaledName().equals(ID_ATTRIBUTE_NAME);
}

/** Validates things that were not validated otherwise */
/** Initialized Validates things that were not validated otherwise */
void initAndValidate() {
makeRegularAndNullableWithValidation();
makeRegularIfContainsWildcards();
makeRegularIfDefaultWithValidation();
}

private void makeRegularIfDefaultWithValidation() {
if (isGenerateDefault && isContainerType()) {
regularAttribute = true;
reporter.withElement(element)
.forAnnotation(Value.Default.class)
.warning("@Value.Default on a container attribute make it lose it's special treatment");
}
}

private void makeRegularAndNullableWithValidation() {
for (AnnotationMirror annotation : element.getAnnotationMirrors()) {
if (annotation.getAnnotationType().asElement().getSimpleName().contentEquals(NULLABLE_SIMPLE_NAME)) {
if (isPrimitive()) {
Expand All @@ -763,14 +778,12 @@ void initAndValidate() {
}
}
}
}

if (isGenerateDefault && isContainerType()) {
// ad-hoc. stick it here, but should work
private void makeRegularIfContainsWildcards() {
// I hope this check isn't too simplistic
if (returnTypeName.indexOf('?') >= 0) {
regularAttribute = true;

reporter.withElement(element)
.forAnnotation(Value.Default.class)
.warning("@Value.Default on a container attribute make it lose it's special treatment");
}
}

Expand Down

0 comments on commit 4b21841

Please sign in to comment.