private String simpleName(final JType type) { String binary = type.getQualifiedBinaryName(); final int last = binary.lastIndexOf('.'); if (last != -1) { binary = binary.substring(last + 1); } return binary.replace('$', '.'); }
private static boolean isVoidMethod(JMethod method) { return VOID_QUALIFIED_NAME.equals(method.getReturnType().getQualifiedBinaryName()); }
private static boolean isVoidMethod(JMethod method) { return VOID_QUALIFIED_NAME.equals(method.getReturnType().getQualifiedBinaryName()); }
public static Class<?> getClass(JType type){ if (type.isPrimitive()==null){ try { return Class.forName(type.getQualifiedBinaryName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } }else{ try { return Class.forName(type.isPrimitive().getQualifiedBoxedSourceName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } } return null; }
/** * Given a JType, return the binary name of the class that is most proximately * assignable to the type. This method will resolve type parameters as well as * wildcard types. */ public static String getQualifiedBaseBinaryName(JType type) { return ensureBaseType(type).getErasedType().getQualifiedBinaryName(); }
/** * Given a JType, return the binary name of the class that is most proximately * assignable to the type. This method will resolve type parameters as well as * wildcard types. */ public static String getQualifiedBaseBinaryName(JType type) { return ensureBaseType(type).getErasedType().getQualifiedBinaryName(); }
private static boolean isJUnitTestMethod(JMethod m) { return m.isPublic() && m.getName().startsWith("test") && m.getParameters().length == 0 && m.getReturnType().getQualifiedBinaryName().equals(Void.TYPE.getName()); } }
private static boolean isJUnitTestMethod(JMethod m) { return m.isPublic() && m.getName().startsWith("test") && m.getParameters().length == 0 && m.getReturnType().getQualifiedBinaryName().equals(Void.TYPE.getName()); } }
public InjectServiceCreator(JType viewType, JField serviceField) { this.viewType = viewType; this.serviceField = serviceField; this.serviceName = serviceField.getType().getQualifiedSourceName(); Class fieldClass; try { fieldClass = this.getClass().getClassLoader().loadClass(serviceField.getType().getQualifiedBinaryName()); if (ServiceProxy.class.isAssignableFrom(fieldClass)) { this.declareProxy = false; this.proxyTypeName = serviceField.getType().getQualifiedSourceName(); } else { this.proxyTypeName = "_" + serviceField.getName() + "ServiceProxy"; } } catch (ClassNotFoundException e) { throw new RuntimeException(e.getMessage(), e); } }
public InjectServiceCreator(JType viewType, JField serviceField) { this.viewType = viewType; this.serviceField = serviceField; this.serviceName = serviceField.getType().getQualifiedSourceName(); Class fieldClass; try { fieldClass = this.getClass().getClassLoader().loadClass(serviceField.getType().getQualifiedBinaryName()); if (ServiceProxy.class.isAssignableFrom(fieldClass)) { this.declareProxy = false; this.proxyTypeName = serviceField.getType().getQualifiedSourceName(); } else { this.proxyTypeName = "_" + serviceField.getName() + "ServiceProxy"; } } catch (ClassNotFoundException e) { throw new RuntimeException(e.getMessage(), e); } }
public static JConstructor findConstructor(TreeLogger logger, JClassType type, List<String> params, boolean declared) { loop: for (JConstructor ctor : type.getConstructors()) { JType[] types = ctor.getParameterTypes(); if (types.length == params.size()) { for (int i = 0, m = types.length; i < m; i++ ) { String typeName = types[i].getErasedType().getQualifiedBinaryName(); while (typeName.startsWith("[")) { typeName = typeName.substring(1)+"[]"; } if (!params.get(i).equals(typeName)) { logger.log(Type.DEBUG, "constructor with different signature; " +"("+params+") mismatches at index "+i+" with value "+typeName); continue loop; } } return ctor; } } return declared || type.getSuperclass() == null ? null: findConstructor(logger, type.getSuperclass(), params, declared); }
public static JConstructor findConstructor(final TreeLogger logger, final JClassType type, final List<String> params, final boolean declared) { loop: for (final JConstructor ctor : type.getConstructors()) { final JType[] types = ctor.getParameterTypes(); if (types.length == params.size()) { for (int i = 0, m = types.length; i < m; i++ ) { String typeName = types[i].getErasedType().getQualifiedBinaryName(); while (typeName.startsWith("[")) { typeName = typeName.substring(1)+"[]"; } if (!params.get(i).equals(typeName)) { logger.log(Type.DEBUG, "constructor with different signature; " +"("+params+") mismatches at index "+i+" with value "+typeName); continue loop; } } return ctor; } } return declared || type.getSuperclass() == null ? null: findConstructor(logger, type.getSuperclass(), params, declared); }
@Override public String getFullyQualifiedName() { if (fqcn != null) { return fqcn; } if (isArray()) { if (getOuterComponentType().isPrimitive()) { fqcn = getInternalName(); } else { fqcn = getInternalName().replace('/', '.'); } } else { fqcn = getEnclosedMetaObject().getQualifiedBinaryName(); } return fqcn; }
@Override public String getFullyQualifiedName() { if (fqcn != null) { return fqcn; } if (isArray()) { if (getOuterComponentType().isPrimitive()) { fqcn = getInternalName(); } else { fqcn = getInternalName().replace('/', '.'); } } else { fqcn = getEnclosedMetaObject().getQualifiedBinaryName(); } return fqcn; }
if (types.length == params.size()) { for (int i = 0, m = types.length; i < m; i++ ) { String typeName = types[i].getErasedType().getQualifiedBinaryName(); while (typeName.startsWith("[")) { typeName = typeName.substring(1)+"[]";
if (types.length == params.size()) { for (int i = 0, m = types.length; i < m; i++ ) { String typeName = types[i].getErasedType().getQualifiedBinaryName(); while (typeName.startsWith("[")) { typeName = typeName.substring(1)+"[]";
protected String toFormStringExpression(JParameter argument, Style classStyle) throws UnableToCompleteException { JType type = argument.getType(); String expr = argument.getName(); if (type.isPrimitive() != null) { return "\"\"+" + expr; } if (STRING_TYPE == type) { return expr; } if (type.isClass() != null && isOverlayArrayType(type.isClass())) { return "(new " + JSON_ARRAY_CLASS + "(" + expr + ")).toString()"; } if (type.isClass() != null && OVERLAY_VALUE_TYPE.isAssignableFrom(type.isClass())) { return "(new " + JSON_OBJECT_CLASS + "(" + expr + ")).toString()"; } if ((!isThrowable(type) && type.getQualifiedBinaryName().startsWith("java.lang.")) || type.isEnum() != null) { return String.format("(%s != null ? %s.toString() : null)", expr, expr); } Json jsonAnnotation = getAnnotation(argument, Json.class); Style style = jsonAnnotation != null ? jsonAnnotation.style() : classStyle; return locator.encodeExpression(type, expr, style) + ".toString()"; }
protected String toFormStringExpression(JParameter argument, Style classStyle) throws UnableToCompleteException { JType type = argument.getType(); String expr = argument.getName(); if (type.isPrimitive() != null) { return "\"\"+" + expr; } if (STRING_TYPE == type) { return expr; } if (type.isClass() != null && isOverlayArrayType(type.isClass())) { return "(new " + JSON_ARRAY_CLASS + "(" + expr + ")).toString()"; } if (type.isClass() != null && OVERLAY_VALUE_TYPE.isAssignableFrom(type.isClass())) { return "(new " + JSON_OBJECT_CLASS + "(" + expr + ")).toString()"; } if ((!isThrowable(type) && type.getQualifiedBinaryName().startsWith("java.lang.")) || type.isEnum() != null) { return String.format("(%s != null ? %s.toString() : null)", expr, expr); } Json jsonAnnotation = getAnnotation(argument, Json.class); Style style = jsonAnnotation != null ? jsonAnnotation.style() : classStyle; return locator.encodeExpression(type, expr, style) + ".toString()"; }