示例#1
0
 @Override
 public <E> E get(Class<E> type, String attrName, E defaultValue) {
   JsonNode json = data.get(attrName);
   if (json == null) {
     return defaultValue;
   }
   return model.readObject(type, json.traverse());
 }
示例#2
0
 @Override
 public <E> E get(Class<E> type, String attrName) {
   JsonNode json = data.get(attrName);
   if (json == null) {
     throw new ConfigException("Attribute " + attrName + " is required but not set");
   }
   return model.readObject(type, json.traverse());
 }
  @Override
  public ActionItem deserialize(JsonParser jp, DeserializationContext ctxt)
      throws IOException, JsonProcessingException {
    ObjectNode objectNode = jp.readValueAsTree();
    JsonNode wrapped = objectNode.get("actionItemType");
    JsonParser parser = wrapped.traverse();
    parser.setCodec(jp.getCodec());
    ActionItemType actionItemType = parser.readValueAs(ActionItemType.class);

    wrapped = objectNode.get("actionItemId");
    parser = wrapped.traverse();
    parser.setCodec(jp.getCodec());
    Long actionItemId = parser.getValueAsLong();

    wrapped = objectNode.get("actionItemCreateDate");
    parser = wrapped.traverse();
    parser.setCodec(jp.getCodec());
    Date actionItemCreateDate = new Date(parser.getValueAsLong());

    wrapped = objectNode.get("actionItemName");
    parser = wrapped.traverse();
    parser.setCodec(jp.getCodec());
    String actionItemName = parser.getValueAsString();

    wrapped = objectNode.get("actionItemDueDate");
    parser = wrapped.traverse();
    parser.setCodec(jp.getCodec());
    Date actionItemDueDate = new Date(parser.getValueAsLong());

    wrapped = objectNode.get("discussionId");
    parser = wrapped.traverse();
    parser.setCodec(jp.getCodec());
    Long discussionId = parser.getValueAsLong();

    wrapped = objectNode.get("owner");
    parser = wrapped.traverse();
    parser.setCodec(jp.getCodec());
    MmrActionItemUser owner = parser.readValueAs(MmrActionItemUser.class);

    wrapped = objectNode.get("assignees");
    parser = wrapped.traverse();
    parser.setCodec(jp.getCodec());
    List<MmrActionItemUser> assignees =
        parser.readValueAs(new TypeReference<List<MmrActionItemUser>>() {});

    wrapped = objectNode.get("actionItemStatus");
    parser = wrapped.traverse();
    parser.setCodec(jp.getCodec());
    ActionItemStatus actionItemStatus = parser.readValueAs(ActionItemStatus.class);

    ActionItem actionItem = new UntypedActionItem();
    actionItem.setActionItemType(actionItemType);
    actionItem.setActionItemId(actionItemId);
    actionItem.setActionItemStatus(actionItemStatus);
    actionItem.setAssignees(assignees);
    actionItem.setActionItemCreateDate(actionItemCreateDate);
    actionItem.setActionItemDueDate(actionItemDueDate);
    actionItem.setActionItemName(actionItemName);
    actionItem.setDiscussionId(discussionId);
    actionItem.setOwner(owner);

    return actionItem;
  }