本文整理汇总了Java中com.google.gwt.core.ext.typeinfo.JType.isPrimitive方法的典型用法代码示例。如果您正苦于以下问题:Java JType.isPrimitive方法的具体用法?Java JType.isPrimitive怎么用?Java JType.isPrimitive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.core.ext.typeinfo.JType
的用法示例。
在下文中一共展示了JType.isPrimitive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: accept
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
public void accept(JType type, TypeVisitor tv){
if (type.isAnnotation() != null){
tv.visitAnnotationType(type.isAnnotation());
} else if (type.isArray() != null){
tv.visitArrayType(type.isArray());
}else if (type.isEnum() != null){
tv.visitEnumType(type.isEnum());
}else if (type.isGenericType() != null){
tv.visitGenericType(type.isGenericType());
}else if (type.isParameterized() != null){
tv.visitParameterizedType(type.isParameterized());
}else if (type.isPrimitive() != null){
tv.visitPrimitiveType(type.isPrimitive());
}else if (type.isRawType() != null){
tv.visitRawType(type.isRawType());
}else if (type.isTypeParameter() != null){
tv.visitTypeParameter(type.isTypeParameter());
}else if (type.isWildcard() != null){
tv.visitWildcardType(type.isWildcard());
}
}
示例2: isNumber
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private boolean isNumber(JType returnType)
{
JPrimitiveType primitiveType = returnType.isPrimitive();
JClassType rt;
if (primitiveType != null)
{
rt = findType(primitiveType.getQualifiedBoxedSourceName());
}
else
{
rt = findType(returnType.getQualifiedSourceName());
}
for (JClassType superType : rt.getFlattenedSupertypeHierarchy())
{
if (isItThisType(superType, Number.class))
{
return true;
}
}
return false;
}
示例3: typeName
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
/**
* @param boxed true if the primitive should be boxed. Useful when use in a parameterized type.
* @param type the type
*
* @return the {@link TypeName}
*/
public TypeName typeName( boolean boxed, JType type ) {
if ( null != type.isPrimitive() ) {
return primitiveName( type.isPrimitive(), boxed );
} else if ( null != type.isParameterized() ) {
return parameterizedName( type.isParameterized() );
} else if ( null != type.isGenericType() ) {
return genericName( type.isGenericType() );
} else if ( null != type.isArray() ) {
return arrayName( type.isArray() );
} else if ( null != type.isTypeParameter() ) {
return typeVariableName( type.isTypeParameter() );
} else if ( null != type.isWildcard() ) {
return wildcardName( type.isWildcard() );
} else {
return className( type.isClassOrInterface() );
}
}
示例4: rawName
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
/**
* @param boxed true if the primitive should be boxed. Useful when use in a parameterized type.
* @param type type to convert
*
* @return the raw {@link TypeName} without parameter
*/
public TypeName rawName( boolean boxed, JType type ) {
if ( null != type.isPrimitive() ) {
return primitiveName( type.isPrimitive(), boxed );
} else if ( null != type.isParameterized() ) {
return className( type.isParameterized().getRawType() );
} else if ( null != type.isGenericType() ) {
return className( type.isGenericType().getRawType() );
} else if ( null != type.isArray() ) {
return arrayName( type.isArray() );
} else if ( null != type.isTypeParameter() ) {
return typeVariableName( type.isTypeParameter() );
} else {
return className( type.isClassOrInterface() );
}
}
示例5: isPrimitive
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private boolean isPrimitive(JType clazz){
if(clazz == null){
return false;
}else if(clazz.isPrimitive() != null || String.class.getName().equalsIgnoreCase(clazz.getQualifiedSourceName())){
return true;
}else if(clazz.isArray() != null){ //Array should be considered as primitive type
return true;
}else{
String qualifiedSourceName = clazz.getQualifiedSourceName();
for (JPrimitiveType primitiveType : JPrimitiveType.values()) {
if(primitiveType.getQualifiedBoxedSourceName().equalsIgnoreCase(qualifiedSourceName) ||
primitiveType.getQualifiedSourceName().equalsIgnoreCase(qualifiedSourceName)){
return true;
}
}
return false;
}
}
示例6: isValideType
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private boolean isValideType(JType type){
if(type == null)
return false;
if(type.isInterface() != null)
return false;
if(type.isPrimitive() != null)
return true;
JClassType aClass = type.isClass();
if(aClass != null && (aClass.isAssignableTo(serializableIntf) || aClass.isAssignableTo(isSerializableIntf))){
return true;
}
JArrayType array = type.isArray();
if(array == null) return false;
return isValideType(array.getComponentType());
}
示例7: getFirstParameterType
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private String getFirstParameterType(JMethod method) {
// If the parameter type is primitive, box it
JType type = method.getParameterTypes()[0];
if (type.isPrimitive() != null) {
if (type.isPrimitive() == JPrimitiveType.BOOLEAN) {
return Boolean.class.getName();
} else if (type.isPrimitive() == JPrimitiveType.BYTE) {
return Byte.class.getName();
} else if (type.isPrimitive() == JPrimitiveType.CHAR) {
return Character.class.getName();
} else if (type.isPrimitive() == JPrimitiveType.DOUBLE) {
return Double.class.getName();
} else if (type.isPrimitive() == JPrimitiveType.FLOAT) {
return Float.class.getName();
} else if (type.isPrimitive() == JPrimitiveType.INT) {
return Integer.class.getName();
} else if (type.isPrimitive() == JPrimitiveType.LONG) {
return Long.class.getName();
} else if (type.isPrimitive() == JPrimitiveType.SHORT) {
return Short.class.getName();
}
}
// Otherwise return the fully-qualified type name
return type.getQualifiedSourceName();
}
示例8: generateInternalSet
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private void generateInternalSet(TreeLogger logger, SourceWriter srcWriter) {
srcWriter.println("protected <P> void internalSet(%s bean, String fieldName, P value){",
this.beanType.getSimpleSourceName());
srcWriter.indent();
for (String propertyName : this.propertyTypes.keySet()) {
JType propertyType = this.propertyTypes.get(propertyName);
JPrimitiveType primitiveType = propertyType.isPrimitive();
JMethod setter = this.setters.get(propertyName);
if (setter != null) {
if (primitiveType != null) {
srcWriter.println(
"if(\"%s\".equals(fieldName)){ bean.%s((%s) PrimitiveUtils.asPrimitive((%s)value)); }",
propertyName, setter.getName(), propertyType.getSimpleSourceName(),
primitiveType.getQualifiedBoxedSourceName());
} else {
srcWriter.println("if(\"%s\".equals(fieldName)){ bean.%s((%s) value); }", propertyName,
setter.getName(),
propertyType.getSimpleSourceName());
}
} else if (this.publicFields.containsKey(propertyName)) {
if (primitiveType != null) {
srcWriter
.println("if(\"%s\".equals(fieldName)){ bean.%s = PrimitiveUtils.asPrimitive((%s) value); }",
propertyName, propertyName, primitiveType.getQualifiedBoxedSourceName());
} else {
srcWriter
.println("if(\"%s\".equals(fieldName)){ bean.%s = (%s) value; }", propertyName, propertyName,
propertyType.getSimpleSourceName());
}
}
}
srcWriter.outdent();
srcWriter.println("}");
}
示例9: getSourceWriter
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private SourceWriter getSourceWriter(PrintWriter printWriter, GeneratorContext ctx) {
String packageName =
this.proxyModelQualifiedName.indexOf('.') == -1 ? "" : this.proxyModelQualifiedName.substring(0,
this.proxyModelQualifiedName.lastIndexOf('.'));
String className =
this.proxyModelQualifiedName.indexOf('.') == -1 ? this.proxyModelQualifiedName
: this.proxyModelQualifiedName
.substring(this.proxyModelQualifiedName.lastIndexOf('.') + 1,
this.proxyModelQualifiedName.length());
ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className);
composerFactory.addImport(Map.class.getName());
composerFactory.addImport(Maps.class.getName());
composerFactory.addImport(GWT.class.getName());
composerFactory.addImport(Model.class.getName());
composerFactory.addImport(AbstractModel.class.getName());
composerFactory.addImport(ModelCollection.class.getName());
composerFactory.addImport(PropertyDescription.class.getName());
composerFactory.addImport(PrimitiveUtils.class.getName());
composerFactory.addImport(this.beanType.getQualifiedSourceName());
composerFactory.addImport("fr.putnami.pwt.core.editor.client.validator.*");
for (JType jType : this.imports) {
if (jType.isPrimitive() != null) {
continue;
}
composerFactory.addImport(jType.getQualifiedSourceName());
}
for (String submodel : this.subModels.values()) {
composerFactory.addImport(submodel);
}
composerFactory
.setSuperclass(AbstractModel.class.getSimpleName() + "<" + this.beanType.getSimpleSourceName() + ">");
return composerFactory.createSourceWriter(ctx, printWriter);
}
示例10: getSourceWriter
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private SourceWriter getSourceWriter(PrintWriter printWriter, GeneratorContext ctx) {
String packageName = this.handlerType.getPackage().getName();
String className =
this.proxyModelQualifiedName.indexOf('.') == -1 ?
this.proxyModelQualifiedName : this.proxyModelQualifiedName.substring(
this.proxyModelQualifiedName.lastIndexOf('.') + 1, this.proxyModelQualifiedName.length());
ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className);
composerFactory.addImport(AsyncCallback.class.getName());
composerFactory.addImport(AbstractServiceBinder.class.getName());
composerFactory.addImport(Arrays.class.getName());
composerFactory.addImport(Lists.class.getName());
composerFactory.addImport(CommandDefinition.class.getName());
composerFactory.addImport(CommandParam.class.getName());
composerFactory.addImport(CallbackAdapter.class.getName());
composerFactory.addImport(CommandController.class.getName());
composerFactory.addImport(this.serviceType.getQualifiedSourceName());
composerFactory.addImport(this.serviceBinderType.getQualifiedSourceName());
for (JType jType : this.imports) {
if (jType.isPrimitive() != null) {
continue;
}
composerFactory.addImport(jType.getQualifiedSourceName());
}
composerFactory.setSuperclass(AbstractServiceBinder.class.getSimpleName()
+ "<" + this.handlerType.getSimpleSourceName() + ", " + this.serviceType.getSimpleSourceName() + ">");
composerFactory.addImplementedInterface(this.serviceType.getSimpleSourceName());
composerFactory.addImplementedInterface(this.serviceBinderType.getSimpleSourceName());
return composerFactory.createSourceWriter(ctx, printWriter);
}
示例11: getSourceWriter
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private SourceWriter getSourceWriter(PrintWriter printWriter, GeneratorContext ctx) {
String packageName = this.handlerType.getPackage().getName();
String className =
this.proxyModelQualifiedName.indexOf('.') == -1 ?
this.proxyModelQualifiedName : this.proxyModelQualifiedName.substring(
this.proxyModelQualifiedName.lastIndexOf('.') + 1, this.proxyModelQualifiedName.length());
ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className);
composerFactory.addImport(AbstractServiceBinder.class.getName());
composerFactory.addImport(Arrays.class.getName());
composerFactory.addImport(Lists.class.getName());
composerFactory.addImport(MethodCallbackAdapter.class.getName());
composerFactory.addImport(Method.class.getName());
composerFactory.addImport(CompositeMethodCallback.class.getName());
composerFactory.addImport(CallbackAdapter.class.getName());
composerFactory.addImport(REST.class.getName());
composerFactory.addImport(GWT.class.getName());
composerFactory.addImport(this.serviceType.getQualifiedSourceName());
composerFactory.addImport(this.serviceBinderType.getQualifiedSourceName());
for (JType jType : this.imports) {
if (jType.isPrimitive() != null) {
continue;
}
composerFactory.addImport(jType.getQualifiedSourceName());
}
composerFactory.setSuperclass(AbstractServiceBinder.class.getSimpleName()
+ "<" + this.handlerType.getSimpleSourceName() + ", " + this.serviceType.getSimpleSourceName() + ">");
composerFactory.addImplementedInterface(this.serviceType.getSimpleSourceName());
composerFactory.addImplementedInterface(this.serviceBinderType.getSimpleSourceName());
return composerFactory.createSourceWriter(ctx, printWriter);
}
示例12: getBoxedTypeAsString
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
/**
* Returns a string representation of "type" converting primitives to their boxed counterpart
* @param type
* @return
*/
protected String getBoxedTypeAsString(JType type){
String name = type.getQualifiedSourceName();
JPrimitiveType primitive = type.isPrimitive();
if (primitive!=null)
name = primitive.getQualifiedBoxedSourceName();
return name;
}
示例13: printMethod
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
/**
* Generate the implementation of a single method.
*
* @param out where to print the method to
* @param method the method
* @param typeName type name of the containing proxy class
*/
private void printMethod(PrintWriter out, JMethod method, String typeName) {
// Build parameter lists
int i = 0;
StringBuilder actualParamsBuilder = new StringBuilder();
StringBuilder formalParamsBuilder = new StringBuilder();
for (JParameter param : method.getParameters()) {
if (i != 0) {
actualParamsBuilder.append(", ");
formalParamsBuilder.append(", ");
}
String paramType = param.getType().getParameterizedQualifiedSourceName();
String paramName = "p" + i++;
actualParamsBuilder.append(paramName);
formalParamsBuilder.append(paramType + " " + paramName);
}
String actualParams = actualParamsBuilder.toString();
String formalParams = formalParamsBuilder.toString();
// Information about the return type
JType returnType = method.getReturnType();
boolean hasReturnValue = !returnType.getSimpleSourceName().equals("void");
JPrimitiveType primitiveReturnType = returnType.isPrimitive();
String resultType =
primitiveReturnType != null ? primitiveReturnType.getQualifiedBoxedSourceName()
: returnType.getParameterizedQualifiedSourceName();
String callbackType = AsyncCallback.class.getName() + "<" + resultType + ">";
// Print method
out.println(" public void " + method.getName() + "(" + formalParams
+ (formalParams.isEmpty() ? "" : ", ") + "final " + callbackType + " callback" + ") {");
out.println(" fireStart(\"" + method.getName() + "\"" + (actualParams.isEmpty() ? "" : ", ")
+ actualParams + ");");
out.println(" proxy." + method.getName() + "(" + actualParams
+ (actualParams.isEmpty() ? "" : ", ") + "new " + callbackType + "() {");
out.println(" public void onSuccess(" + resultType + " result) {");
out.println(" " + outcome(method, "Success", "result"));
out.println(" }");
out.println(" public void onFailure(Throwable caught) {");
out.println(" " + outcome(method, "Failure", "caught"));
out.println(" }");
out.println(" });");
out.println(" }");
}
示例14: printMockMethodBody
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private void printMockMethodBody(SourceWriter sourceWriter, JMethod method,
int methodNo, String newClassName) {
JParameter[] args = method.getParameters();
String callVar = freeVariableName("call", args);
sourceWriter.print("Call %s = new Call(this, %s.methods[%d]", callVar, newClassName, methodNo);
int argsCount = method.isVarArgs() ? args.length - 1 : args.length;
for (int i = 0; i < argsCount; i++) {
sourceWriter.print(", %s", args[i].getName());
}
sourceWriter.println(");");
if (method.isVarArgs()) {
sourceWriter.println("%s.addVarArgument(%s);", callVar, args[args.length - 1].getName());
}
sourceWriter.println("try {");
sourceWriter.indent();
if (!isVoid(method)) {
sourceWriter.print("return (");
JType returnType = method.getReturnType();
JPrimitiveType primitiveType = returnType.isPrimitive();
if (primitiveType != null) {
sourceWriter.print(primitiveType.getQualifiedBoxedSourceName());
} else if (returnType.isTypeParameter() != null) {
sourceWriter.print(returnType.isTypeParameter().getName());
} else {
sourceWriter.print(returnType.getQualifiedSourceName());
}
sourceWriter.print(") ");
}
sourceWriter.println("this.mocksControl.invoke(%s).answer(%s.getArguments().toArray());",
callVar, callVar);
sourceWriter.outdent();
String exceptionVar = freeVariableName("exception", args);
sourceWriter.println("} catch (Throwable %s) {", exceptionVar);
sourceWriter.indent();
String assertionError = AssertionErrorWrapper.class.getCanonicalName();
sourceWriter.println("if (%s instanceof %s) throw (AssertionError) " +
"((%s) %s).getAssertionError().fillInStackTrace();",
exceptionVar, assertionError, assertionError, exceptionVar);
for (JClassType exception : method.getThrows()) {
printRethrowException(sourceWriter, exceptionVar, exception.getQualifiedSourceName());
}
printRethrowException(sourceWriter, exceptionVar, "RuntimeException");
printRethrowException(sourceWriter, exceptionVar, "Error");
sourceWriter.println("throw new UndeclaredThrowableException(%s);", exceptionVar);
sourceWriter.outdent();
sourceWriter.println("}");
}
示例15: getQualifiedSourceNonPrimitiveType
import com.google.gwt.core.ext.typeinfo.JType; //导入方法依赖的package包/类
private String getQualifiedSourceNonPrimitiveType(final JType elementType) {
final JPrimitiveType primitive = elementType.isPrimitive();
return primitive == null ? elementType.getQualifiedSourceName()
: primitive.getQualifiedBoxedSourceName();
}