Examples of JsonProtocolModelParseException


Examples of org.chromium.sdk.internal.protocolparser.JsonProtocolModelParseException

    this.isNullable = isNullable;

    try {
      this.methodValueOf = enumClass.getMethod("valueOf", String.class);
    } catch (NoSuchMethodException e) {
      throw new JsonProtocolModelParseException(
          "Failed to find valueOf method for parsing strings", e);
    }
  }
View Full Code Here

Examples of org.chromium.sdk.internal.protocolparser.JsonProtocolModelParseException

    }
    if (results.size() == 0) {
      return null;
    }
    if (results.size() > 1) {
      throw new JsonProtocolModelParseException("Too many constraints for field getter " + m);
    }
    return results.get(0);
  }
View Full Code Here

Examples of org.chromium.sdk.internal.protocolparser.JsonProtocolModelParseException

      if (containsSafe(visitedInterfaces, clazz)) {
        return;
      }
      visitedInterfaces.add(clazz);
      if (!clazz.isInterface()) {
        throw new JsonProtocolModelParseException(
            "Parser root type must be an interface: " + clazz);
      }
      JsonParserRoot jsonParserRoot = clazz.getAnnotation(JsonParserRoot.class);
      if (jsonParserRoot == null) {
        throw new JsonProtocolModelParseException(
            JsonParserRoot.class.getCanonicalName() + " annotation is expected in " + clazz);
      }
      for (Method m : clazz.getMethods()) {
        JsonParseMethod jsonParseMethod = m.getAnnotation(JsonParseMethod.class);
        if (jsonParseMethod == null) {
          throw new JsonProtocolModelParseException(
              JsonParseMethod.class.getCanonicalName() + " annotation is expected in " + clazz);
        }

        Class<?>[] exceptionTypes = m.getExceptionTypes();
        if (exceptionTypes.length > 1) {
          throw new JsonProtocolModelParseException("Too many exception declared in " + m);
        }
        if (exceptionTypes.length < 1 || exceptionTypes[0] != JsonProtocolParseException.class) {
          throw new JsonProtocolModelParseException(
              JsonProtocolParseException.class.getCanonicalName() +
              " exception must be declared in " + m);
        }

        Type returnType = m.getGenericReturnType();
        TypeHandler<?> typeHandler = type2TypeHandler.get(returnType);
        if (typeHandler == null) {
          throw new JsonProtocolModelParseException("Unknown return type in " + m);
        }

        Type[] arguments = m.getGenericParameterTypes();
        if (arguments.length != 1) {
          throw new JsonProtocolModelParseException("Exactly one argument is expected in " + m);
        }
        Type argument = arguments[0];
        MethodDelegate delegate;
        if (argument == JSONObject.class) {
          delegate = new ParseDelegate(typeHandler);
        } else if (argument == Object.class) {
          delegate = new ParseDelegate(typeHandler);
        } else {
          throw new JsonProtocolModelParseException("Unrecognized argument type in " + m);
        }
        methodMap.put(m, delegate);
      }

      for (Type baseType : clazz.getGenericInterfaces()) {
        if (baseType instanceof Class == false) {
          throw new JsonProtocolModelParseException("Base interface must be class in " + clazz);
        }
        Class<?> baseClass = (Class<?>) baseType;
        parseInterfaceRecursive(baseClass);
      }
    }
View Full Code Here

Examples of org.chromium.sdk.internal.protocolparser.JsonProtocolModelParseException

    }

    private <T> TypeHandler<T> createTypeHandler(Class<T> typeClass)
        throws JsonProtocolModelParseException {
      if (!typeClass.isInterface()) {
        throw new JsonProtocolModelParseException("Json model type should be interface: " +
            typeClass.getName());
      }

      FieldProcessor<T> fields = new FieldProcessor<T>(typeClass);
View Full Code Here

Examples of org.chromium.sdk.internal.protocolparser.JsonProtocolModelParseException

        }
        RefToType<?> ref = getTypeRef(typeClass);
        if (ref != null) {
          return createJsonParser(ref, declaredNullable, isSubtyping);
        }
        throw new JsonProtocolModelParseException("Method return type " + type +
            " (simple class) not supported");
      } else if (type instanceof ParameterizedType) {
        ParameterizedType parameterizedType = (ParameterizedType) type;
        if (parameterizedType.getRawType() == List.class) {
          Type argumentType = parameterizedType.getActualTypeArguments()[0];
          if (argumentType instanceof WildcardType) {
            WildcardType wildcard = (WildcardType) argumentType;
            if (wildcard.getLowerBounds().length == 0 && wildcard.getUpperBounds().length == 1) {
              argumentType = wildcard.getUpperBounds()[0];
            }
          }
          SlowParser<?> componentParser =
              getFieldTypeParser(argumentType, false, false, loadStrategy);
          return createArrayParser(componentParser, declaredNullable, loadStrategy);
        } else {
          throw new JsonProtocolModelParseException("Method return type " + type +
              " (generic) not supported");
        }
      } else {
        throw new JsonProtocolModelParseException("Method return type " + type + " not supported");
      }
    }
View Full Code Here

Examples of org.chromium.sdk.internal.protocolparser.JsonProtocolModelParseException

    }

    private void nullableIsNotSupported(boolean declaredNullable)
        throws JsonProtocolModelParseException {
      if (declaredNullable) {
        throw new JsonProtocolModelParseException("The type cannot be declared nullable");
      }
    }
View Full Code Here

Examples of org.chromium.sdk.internal.protocolparser.JsonProtocolModelParseException

        if (parameterizedType.getRawType() != JsonSubtype.class) {
          continue;
        }
        Type param = parameterizedType.getActualTypeArguments()[0];
        if (param instanceof Class == false) {
          throw new JsonProtocolModelParseException("Unexpected type of superclass " + param);
        }
        Class<?> paramClass = (Class<?>) param;
        if (result != null) {
          throw new JsonProtocolModelParseException("Already has superclass " +
              result.getTypeClass().getName());
        }
        result = getTypeRef(paramClass);
        if (result == null) {
          throw new JsonProtocolModelParseException("Unknown base class " + paramClass.getName());
        }
      }
      return result;
    }
View Full Code Here

Examples of org.chromium.sdk.internal.protocolparser.JsonProtocolModelParseException

      FieldProcessor(Class<T> typeClass) throws JsonProtocolModelParseException {
        this.typeClass = typeClass;
        jsonTypeAnn = typeClass.getAnnotation(JsonType.class);
        if (jsonTypeAnn == null) {
          throw new JsonProtocolModelParseException("Not a json model type: " + typeClass);
        }
      }
View Full Code Here

Examples of org.chromium.sdk.internal.protocolparser.JsonProtocolModelParseException

      void go() throws JsonProtocolModelParseException {
        for (Method m : typeClass.getDeclaredMethods()) {
          try {
            processMethod(m);
          } catch (JsonProtocolModelParseException e) {
            throw new JsonProtocolModelParseException("Problem with method " + m, e);
          }
        }
      }
View Full Code Here

Examples of org.chromium.sdk.internal.protocolparser.JsonProtocolModelParseException

        }
      }

      private void processMethod(Method m) throws JsonProtocolModelParseException {
        if (m.getParameterTypes().length != 0) {
          throw new JsonProtocolModelParseException("No parameters expected in " + m);
        }
        JsonOverrideField overrideFieldAnn = m.getAnnotation(JsonOverrideField.class);
        FieldConditionLogic fieldConditionLogic = FieldConditionLogic.readLogic(m);
        String fieldName = checkAndGetJsonFieldName(m);
        MethodHandler methodHandler;

        JsonSubtypeCasting jsonSubtypeCaseAnn = m.getAnnotation(JsonSubtypeCasting.class);
        if (jsonSubtypeCaseAnn != null) {
          if (fieldConditionLogic != null) {
            throw new JsonProtocolModelParseException(
                "Subtype condition annotation only works with field getter methods");
          }
          if (overrideFieldAnn != null) {
            throw new JsonProtocolModelParseException(
                "Override annotation only works with field getter methods");
          }

          if (jsonTypeAnn.subtypesChosenManually()) {
            if (manualAlgCasesData == null) {
              manualAlgCasesData = new ManualAlgebraicCasesDataImpl();
            }
            methodHandler = processManualSubtypeMethod(m, jsonSubtypeCaseAnn);
          } else {
            if (autoAlgCasesData == null) {
              autoAlgCasesData = new AutoAlgebraicCasesDataImpl();
            }
            if (jsonSubtypeCaseAnn.reinterpret()) {
              throw new JsonProtocolModelParseException(
                  "Option 'reinterpret' is only available with 'subtypes chosen manually'");
            }
            requiresJsonObject = true;
            methodHandler = processAutomaticSubtypeMethod(m);
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.