Example #1
0
 /*     */ public JavaType getType(TypeBindings bindings) /*     */ {
   /*  66 */ TypeVariable[] localTypeParams = this._constructor.getTypeParameters();
   /*     */
   /*  68 */ if ((localTypeParams != null) && (localTypeParams.length > 0)) {
     /*  69 */ bindings = bindings.childInstance();
     /*  70 */ for (TypeVariable var : localTypeParams) {
       /*  71 */ String name = var.getName();
       /*     */
       /*  73 */ bindings._addPlaceholder(name);
       /*     */
       /*  75 */ Type lowerBound = var.getBounds()[0];
       /*  76 */ JavaType type =
           lowerBound == null
               ? TypeFactory.fastSimpleType(Object.class)
               : TypeFactory.type(lowerBound, bindings);
       /*     */
       /*  78 */ bindings.addBinding(var.getName(), type);
       /*     */ }
     /*     */ }
   /*  81 */ return TypeFactory.type(getGenericType(), bindings);
   /*     */ }
Example #2
0
  /**
   * Invokes the given method on the {@code handler} passing the given params (after converting them
   * to beans\objects) to it.
   *
   * @param m the method to invoke
   * @param params the params to pass to the method
   * @return the return value (or null if no return)
   * @throws JsonParseException
   * @throws JsonMappingException
   * @throws IOException
   * @throws IllegalArgumentException
   * @throws IllegalAccessException
   * @throws InvocationTargetException
   */
  private JsonNode invoke(Method m, List<JsonNode> params)
      throws JsonParseException, JsonMappingException, IOException, IllegalArgumentException,
          IllegalAccessException, InvocationTargetException {

    // convert the parameters
    Object[] convertedParams = new Object[params.size()];
    Type[] parameterTypes = m.getGenericParameterTypes();
    for (int i = 0; i < parameterTypes.length; i++) {
      convertedParams[i] =
          mapper.treeToValue(params.get(i), TypeFactory.type(parameterTypes[i]).getRawClass());
    }

    // invoke the method
    Object result = m.invoke(handler, convertedParams);
    return (m.getGenericReturnType() != null) ? mapper.valueToTree(result) : null;
  }
Example #3
0
/*     */   public JsonNode getSchema(SerializerProvider provider, Type typeHint)
/*     */     throws JsonMappingException
/*     */   {
/* 203 */     ObjectNode o = createSchemaNode("array", true);
/* 204 */     if (typeHint != null) {
/* 205 */       JavaType javaType = TypeFactory.type(typeHint);
/* 206 */       if (javaType.isArrayType()) {
/* 207 */         Class componentType = ((ArrayType)javaType).getContentType().getRawClass();
/*     */ 
/* 209 */         if (componentType == Object.class) {
/* 210 */           o.put("items", JsonSchema.getDefaultSchemaNode());
/*     */         } else {
/* 212 */           JsonSerializer ser = provider.findValueSerializer(componentType, this._property);
/* 213 */           JsonNode schemaNode = (ser instanceof SchemaAware) ? ((SchemaAware)ser).getSchema(provider, null) : JsonSchema.getDefaultSchemaNode();
/*     */ 
/* 216 */           o.put("items", schemaNode);
/*     */         }
/*     */       }
/*     */     }
/* 220 */     return o;
/*     */   }
 /**
  * Returns the Jackson {@link JavaType} for the specific class.
  *
  * <p>
  *
  * <p>Default implementation returns {@link TypeFactory#type(java.lang.reflect.Type)}, but this
  * can be overridden in subclasses, to allow for custom generic collection handling. For instance:
  *
  * <p>
  *
  * <pre class="code">
  * protected JavaType getJavaType(Class&lt;?&gt; clazz) {
  * if (List.class.isAssignableFrom(clazz)) {
  * return TypeFactory.collectionType(ArrayList.class, MyBean.class);
  * } else {
  * return super.getJavaType(clazz);
  * }
  * }
  * </pre>
  *
  * @param clazz the class to return the java type for
  * @return the java type
  */
 protected JavaType getJavaType(Class<?> clazz) {
   return TypeFactory.type(clazz);
 }