boolean isAbstract = isAbstract(unwrapped); boolean isOptional = TypeUtils.isOptional(toAdd.getTypeRef()) || TypeUtils.isOptionalInt(toAdd.getTypeRef()) || TypeUtils.isOptionalDouble(toAdd.getTypeRef()) || TypeUtils.isOptionalLong(toAdd.getTypeRef());
final boolean isAbstract = isAbstract(unwrapped); boolean isOptional = TypeUtils.isOptional(property.getTypeRef()) || TypeUtils.isOptionalInt(property.getTypeRef()) || TypeUtils.isOptionalDouble(property.getTypeRef()) || TypeUtils.isOptionalLong(property.getTypeRef());
public Method apply(final Property property) { String prefix = "has"; String methodName = prefix + property.getNameCapitalized(); List<Statement> statements = new ArrayList<Statement>(); if (isPrimitive(property.getTypeRef())) { statements.add(new StringStatement("return true;")); } else if (isList(property.getTypeRef()) || isSet(property.getTypeRef())) { statements.add(new StringStatement("return " + property.getName() + " != null && !" + property.getName() + ".isEmpty();")); } else if (isOptional(property.getTypeRef())|| isOptionalInt(property.getTypeRef()) || isOptionalLong(property.getTypeRef()) || isOptionalDouble(property.getTypeRef())) { statements.add(new StringStatement("return " + property.getName() + " != null && " + property.getName() + ".isPresent();")); } else { statements.add(new StringStatement("return this." + property.getName() + " != null;")); } return new MethodBuilder() .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC)) .withName(methodName) .withReturnType(BOOLEAN_REF) .withArguments() .withNewBlock() .withStatements(statements) .endBlock() .build(); } });
boolean isMap = TypeUtils.isMap(typeRef); boolean isOptional = TypeUtils.isOptional(typeRef); boolean isOptionalInt = TypeUtils.isOptionalInt(typeRef); boolean isOptionalDouble = TypeUtils.isOptionalDouble(typeRef); boolean isOptionalLong = TypeUtils.isOptionalLong(typeRef);
public TypeRef apply(TypeRef type) { if (type instanceof ClassRef) { ClassRef classRef = (ClassRef) type; if (TypeUtils.isOptional(classRef)) { return classRef.getArguments().get(0); } if (TypeUtils.isOptionalInt(classRef)) { return new TypeDefBuilder().withPackageName("java.lang").withName("Integer").build().toReference(); } if (TypeUtils.isOptionalLong(classRef)) { return new TypeDefBuilder().withPackageName("java.lang").withName("Long").build().toReference(); } if (TypeUtils.isOptionalDouble(classRef)) { return new TypeDefBuilder().withPackageName("java.lang").withName("Double").build().toReference(); } } return type; } };
boolean isList = isList(property.getTypeRef()); boolean isSet = isSet(property.getTypeRef()); boolean isOptional = isOptional(property.getTypeRef()) || isOptionalDouble(property.getTypeRef()) || isOptionalInt(property.getTypeRef()) || isOptionalLong(property.getTypeRef());
if (TypeUtils.isOptionalInt(classRef)) { ClassRef optionalRef = Optionals.OPTIONAL_INT.toReference(builderType); return new PropertyBuilder(property).withTypeRef(optionalRef)