Skip to content

Commit

Permalink
Date and list working.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Apr 7, 2017
1 parent dac0df4 commit 3f0ef60
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/wurrly/controllers/Users.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Any userType(
@QueryParam("optionalQueryString") Optional<String> optionalQueryString,
@QueryParam("optionalLong") Optional<Long> optionalLong,
@QueryParam("longValue") Long longValue,
@QueryParam("date") @ApiParam(format="date") Date dateValue,
@QueryParam("dateValue") @ApiParam(format="date") Optional<Date> dateValue,
@QueryParam("numbers") List<Integer> numbers,

@QueryParam("queryFromString") UUID queryFromString,
Expand All @@ -95,6 +95,7 @@ public Any userType(
log.debug("queryEnum: " + queryEnum);
log.debug("optionalQueryEnum: " + optionalQueryEnum);
log.debug("userId: " + userId);
log.debug("numbers: " + numbers);


//
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/wurrly/server/Extractors.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public static <T> java.util.Optional<T> typed(final HttpServerExchange exchange
});
}

public static java.util.Optional<Date> date(final HttpServerExchange exchange,final String name) {


return string(exchange, name).map( ZonedDateTime::parse ).map(ZonedDateTime::toInstant).map(Date::from);

}

public static java.util.Optional<Any> any(final HttpServerExchange exchange )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public enum TypeHandler
OptionalFloatType("$T<Long> $L = $T.floatValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, com.wurrly.server.Extractors.Optional.class, StatementParameterType.STRING),
OptionalDoubleType("$T<Integer> $L = $T.doubleValue(exchange,$S)", false, Optional.class, StatementParameterType.LITERAL, com.wurrly.server.Extractors.Optional.class, StatementParameterType.STRING),


OptionalDateType("$T<$T> $L = $T.date(exchange,$S)", false, Optional.class, java.util.Date.class, StatementParameterType.LITERAL, com.wurrly.server.Extractors.Optional.class, StatementParameterType.STRING),

OptionalModelType("java.util.Optional<$L> $L = $T.typed(exchange,$L)", true, StatementParameterType.LITERAL, StatementParameterType.LITERAL, com.wurrly.server.Extractors.Optional.class, StatementParameterType.LITERAL),

OptionalValueOfType("$T<$T> $L = $T.string(exchange,$S).map($T::valueOf)", false, Optional.class, StatementParameterType.RAW, StatementParameterType.LITERAL,com.wurrly.server.Extractors.Optional.class, StatementParameterType.STRING, StatementParameterType.RAW),
Expand Down Expand Up @@ -182,7 +183,7 @@ else if (handler.parameterTypes[i] instanceof Class)
}
}

log.debug("type: " + parameter.getParameterizedType().getTypeName() + " : " + handler);
log.info("type: " + parameter.getParameterizedType().getTypeName() + " : " + handler);
builder.addStatement(handler.statement, args);
}

Expand Down Expand Up @@ -281,6 +282,10 @@ else if (type.getTypeName().contains("java.lang.String"))
{
return OptionalStringType;
}
else if (type.getTypeName().contains("java.util.Date"))
{
return OptionalDateType;
}
else if (type.getTypeName().contains("java.lang.Boolean"))
{
return OptionalBooleanType;
Expand Down
Empty file modified src/main/resources/swagger/swagger-ui-standalone-preset.js.map
100644 → 100755
Empty file.

0 comments on commit 3f0ef60

Please sign in to comment.