Skip to content

Commit

Permalink
Merge branch 'Adrodoc55-fix/142' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
karneimm committed Nov 8, 2017
2 parents cc97561 + d87c674 commit 55f69cc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,28 +350,30 @@ private void emitParameterAssignment(PropertyM prop, String parameterFieldName,
writer.emitStatement("%s %s", compressedType, parameterFieldName);
writer.beginControlFlow("if (!%s && %s != null)", prop.getIsSetFieldName(), builderFieldName);
writer.emitStatement("%s = %s", parameterFieldName, callBuild);
writer.nextControlFlow("else").emitStatement("%s = %s", parameterFieldName, valueField);
writer.nextControlFlow("else");
writer.emitStatement("%s = %s", parameterFieldName, valueField);
writer.endControlFlow();
} else {
String defaultValue = "null";
if (propertyType.isPrimitive()) {
Class<?> type = ((PrimitiveTypeM) propertyType).getType();
defaultValue = Defaults.defaultValueAsLiteral(type);
}
writer.emitStatement("%s %s = %s", compressedType, parameterFieldName, defaultValue);
if (prop.isOptionalProperty(optional)) {
writer.beginControlFlow("if (%s == null || %s.isPresent())", valueField, valueField);
writer.emitStatement("%s = %s", parameterFieldName, valueField);
writer.emitStatement("%s %s = %s", compressedType, parameterFieldName, valueField);
if (hasBuilderProperties) {
writer.nextControlFlow("else if (%s != null)", builderFieldName);
writer.beginControlFlow("if (%s != null && !%s.isPresent() && %s != null)", valueField, valueField,
builderFieldName);
String basicType = writer.compressType(prop.getBasicPropertyType(optional).getGenericType());
String tempFieldName = "builtValue";
writer.emitStatement("%s %s = %s", basicType, tempFieldName, callBuild);
writer.beginControlFlow("if (%s != null)", tempFieldName);
writer.emitStatement("%s = %s", parameterFieldName, optional.of(tempFieldName));
writer.endControlFlow();
writer.endControlFlow();
}
} else {
String defaultValue = "null";
if (propertyType.isPrimitive()) {
Class<?> type = ((PrimitiveTypeM) propertyType).getType();
defaultValue = Defaults.defaultValueAsLiteral(type);
}
writer.emitStatement("%s %s = %s", compressedType, parameterFieldName, defaultValue);
boolean extraControlFlow = false;
if (propertyType.isPrimitive()) {
writer.beginControlFlow("if (%s.isPresent())", valueField);
Expand All @@ -390,8 +392,8 @@ private void emitParameterAssignment(PropertyM prop, String parameterFieldName,
if (extraControlFlow) {
writer.endControlFlow();
}
writer.endControlFlow();
}
writer.endControlFlow();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,9 @@ public PojoWithGuavaOptionalOptionalConstructorBuilder but() {
*/
public PojoWithGuavaOptionalOptionalConstructor build() {
try {
Optional<Integer> _boxedInt = null;
if (value$boxedInt$com$google$common$base$Optional == null || value$boxedInt$com$google$common$base$Optional.isPresent()) {
_boxedInt = value$boxedInt$com$google$common$base$Optional;
}
Optional<int[]> _array = null;
if (value$array$com$google$common$base$Optional == null || value$array$com$google$common$base$Optional.isPresent()) {
_array = value$array$com$google$common$base$Optional;
}
Optional<List<Integer>> _list = null;
if (value$list$com$google$common$base$Optional == null || value$list$com$google$common$base$Optional.isPresent()) {
_list = value$list$com$google$common$base$Optional;
}
Optional<Integer> _boxedInt = value$boxedInt$com$google$common$base$Optional;
Optional<int[]> _array = value$array$com$google$common$base$Optional;
Optional<List<Integer>> _list = value$list$com$google$common$base$Optional;
PojoWithGuavaOptionalOptionalConstructor result = new PojoWithGuavaOptionalOptionalConstructor(_boxedInt, _array, _list);
return result;
} catch (RuntimeException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,28 +176,22 @@ public PojoWithGuavaOptionalOptionalConstructorWithBuilderPropertiesBuilder but(
@Override
public PojoWithGuavaOptionalOptionalConstructorWithBuilderProperties build() {
try {
Optional<Integer> _boxedInt = null;
if (value$boxedInt$com$google$common$base$Optional == null || value$boxedInt$com$google$common$base$Optional.isPresent()) {
_boxedInt = value$boxedInt$com$google$common$base$Optional;
} else if (builder$boxedInt$com$google$common$base$Optional != null) {
Optional<Integer> _boxedInt = value$boxedInt$com$google$common$base$Optional;
if (value$boxedInt$com$google$common$base$Optional != null && !value$boxedInt$com$google$common$base$Optional.isPresent() && builder$boxedInt$com$google$common$base$Optional != null) {
Integer builtValue = builder$boxedInt$com$google$common$base$Optional.build();
if (builtValue != null) {
_boxedInt = Optional.of(builtValue);
}
}
Optional<int[]> _array = null;
if (value$array$com$google$common$base$Optional == null || value$array$com$google$common$base$Optional.isPresent()) {
_array = value$array$com$google$common$base$Optional;
} else if (builder$array$com$google$common$base$Optional != null) {
Optional<int[]> _array = value$array$com$google$common$base$Optional;
if (value$array$com$google$common$base$Optional != null && !value$array$com$google$common$base$Optional.isPresent() && builder$array$com$google$common$base$Optional != null) {
int[] builtValue = builder$array$com$google$common$base$Optional.build();
if (builtValue != null) {
_array = Optional.of(builtValue);
}
}
Optional<List<Integer>> _list = null;
if (value$list$com$google$common$base$Optional == null || value$list$com$google$common$base$Optional.isPresent()) {
_list = value$list$com$google$common$base$Optional;
} else if (builder$list$com$google$common$base$Optional != null) {
Optional<List<Integer>> _list = value$list$com$google$common$base$Optional;
if (value$list$com$google$common$base$Optional != null && !value$list$com$google$common$base$Optional.isPresent() && builder$list$com$google$common$base$Optional != null) {
List<Integer> builtValue = builder$list$com$google$common$base$Optional.build();
if (builtValue != null) {
_list = Optional.of(builtValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,9 @@ public PojoWithGuavaOptionalOptionalFactoryBuilder but() {
*/
public PojoWithGuavaOptionalOptionalFactory build() {
try {
Optional<Integer> _boxedInt = null;
if (value$boxedInt$com$google$common$base$Optional == null || value$boxedInt$com$google$common$base$Optional.isPresent()) {
_boxedInt = value$boxedInt$com$google$common$base$Optional;
}
Optional<int[]> _array = null;
if (value$array$com$google$common$base$Optional == null || value$array$com$google$common$base$Optional.isPresent()) {
_array = value$array$com$google$common$base$Optional;
}
Optional<List<Integer>> _list = null;
if (value$list$com$google$common$base$Optional == null || value$list$com$google$common$base$Optional.isPresent()) {
_list = value$list$com$google$common$base$Optional;
}
Optional<Integer> _boxedInt = value$boxedInt$com$google$common$base$Optional;
Optional<int[]> _array = value$array$com$google$common$base$Optional;
Optional<List<Integer>> _list = value$list$com$google$common$base$Optional;
PojoWithGuavaOptionalOptionalFactory result = PojoWithGuavaOptionalOptionalFactory.create(_boxedInt, _array, _list);
return result;
} catch (RuntimeException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,28 +176,22 @@ public PojoWithGuavaOptionalOptionalFactoryWithBuilderPropertiesBuilder but() {
@Override
public PojoWithGuavaOptionalOptionalFactoryWithBuilderProperties build() {
try {
Optional<Integer> _boxedInt = null;
if (value$boxedInt$com$google$common$base$Optional == null || value$boxedInt$com$google$common$base$Optional.isPresent()) {
_boxedInt = value$boxedInt$com$google$common$base$Optional;
} else if (builder$boxedInt$com$google$common$base$Optional != null) {
Optional<Integer> _boxedInt = value$boxedInt$com$google$common$base$Optional;
if (value$boxedInt$com$google$common$base$Optional != null && !value$boxedInt$com$google$common$base$Optional.isPresent() && builder$boxedInt$com$google$common$base$Optional != null) {
Integer builtValue = builder$boxedInt$com$google$common$base$Optional.build();
if (builtValue != null) {
_boxedInt = Optional.of(builtValue);
}
}
Optional<int[]> _array = null;
if (value$array$com$google$common$base$Optional == null || value$array$com$google$common$base$Optional.isPresent()) {
_array = value$array$com$google$common$base$Optional;
} else if (builder$array$com$google$common$base$Optional != null) {
Optional<int[]> _array = value$array$com$google$common$base$Optional;
if (value$array$com$google$common$base$Optional != null && !value$array$com$google$common$base$Optional.isPresent() && builder$array$com$google$common$base$Optional != null) {
int[] builtValue = builder$array$com$google$common$base$Optional.build();
if (builtValue != null) {
_array = Optional.of(builtValue);
}
}
Optional<List<Integer>> _list = null;
if (value$list$com$google$common$base$Optional == null || value$list$com$google$common$base$Optional.isPresent()) {
_list = value$list$com$google$common$base$Optional;
} else if (builder$list$com$google$common$base$Optional != null) {
Optional<List<Integer>> _list = value$list$com$google$common$base$Optional;
if (value$list$com$google$common$base$Optional != null && !value$list$com$google$common$base$Optional.isPresent() && builder$list$com$google$common$base$Optional != null) {
List<Integer> builtValue = builder$list$com$google$common$base$Optional.build();
if (builtValue != null) {
_list = Optional.of(builtValue);
Expand Down

0 comments on commit 55f69cc

Please sign in to comment.