/** * Given type assignable to <code>Editor<Foo></code>, return * <code>Foo</code>. It is an error to call this method with a type not * assignable to {@link Editor}. */ static JClassType calculateEditedType(TreeLogger logger, JClassType editorType) throws UnableToCompleteException { JClassType editorIntf = editorType.getOracle().findType( Editor.class.getName()); JClassType parameterization[] = ModelUtils.findParameterizationOf( editorIntf, editorType); if (parameterization != null) { return parameterization[0]; } logger.log(TreeLogger.ERROR, noEditorParameterizationMessage(editorIntf, editorType)); throw new UnableToCompleteException(); }
/** * Given type assignable to <code>Editor<Foo></code>, return * <code>Foo</code>. It is an error to call this method with a type not * assignable to {@link Editor}. */ static JClassType calculateEditedType(TreeLogger logger, JClassType editorType) throws UnableToCompleteException { JClassType editorIntf = editorType.getOracle().findType( Editor.class.getName()); JClassType parameterization[] = ModelUtils.findParameterizationOf( editorIntf, editorType); if (parameterization != null) { return parameterization[0]; } logger.log(TreeLogger.ERROR, noEditorParameterizationMessage(editorIntf, editorType)); throw new UnableToCompleteException(); }
/** * Given type assignable to <code>IsEditor<Foo, FooEditor></code>, return * <code>FooEditor</code>. It is an error to call this method with a type not * assignable to {@link IsEditor}. */ static JClassType calculateIsEditedType(TreeLogger logger, JClassType editorType) throws UnableToCompleteException { JClassType editorIntf = editorType.getOracle().findType( IsEditor.class.getName()); JClassType[] parameterization = ModelUtils.findParameterizationOf( editorIntf, editorType); if (parameterization != null) { return parameterization[0]; } logger.log(TreeLogger.ERROR, noEditorParameterizationMessage(editorIntf, editorType)); throw new UnableToCompleteException(); }
/** * Given type assignable to <code>IsEditor<Foo, FooEditor></code>, return * <code>FooEditor</code>. It is an error to call this method with a type not * assignable to {@link IsEditor}. */ static JClassType calculateIsEditedType(TreeLogger logger, JClassType editorType) throws UnableToCompleteException { JClassType editorIntf = editorType.getOracle().findType( IsEditor.class.getName()); JClassType[] parameterization = ModelUtils.findParameterizationOf( editorIntf, editorType); if (parameterization != null) { return parameterization[0]; } logger.log(TreeLogger.ERROR, noEditorParameterizationMessage(editorIntf, editorType)); throw new UnableToCompleteException(); }
JClassType resolveOwnerType(JClassType interfaceToImplement) throws UnableToCompleteException { TypeOracle oracle = interfaceToImplement.getOracle(); JClassType handlerInterface = oracle.findType(ElementIdHandler.class.getName()).isInterface(); assert handlerInterface != null : "No ElementIdHandler type"; //$NON-NLS-1$ if (!handlerInterface.isAssignableFrom(interfaceToImplement)) { die(String.format("Unexpected input type: %s is not assignable from %s", //$NON-NLS-1$ handlerInterface.getQualifiedSourceName(), interfaceToImplement.getQualifiedSourceName())); } else if (interfaceToImplement.equals(handlerInterface)) { die(String.format("You must declare an interface that extends the %s type", //$NON-NLS-1$ handlerInterface.getSimpleSourceName())); } JClassType[] interfaces = interfaceToImplement.getImplementedInterfaces(); if (interfaces.length != 1) { die(String.format("The type %s extends more than one interface", //$NON-NLS-1$ interfaceToImplement.getQualifiedSourceName())); } JClassType[] parameters = ModelUtils.findParameterizationOf(handlerInterface, interfaceToImplement); if (parameters.length != 1) { die(String.format("The type %s has unexpected number of type parameters", //$NON-NLS-1$ interfaceToImplement.getQualifiedSourceName())); } return parameters[0]; }
public void setMethod(JMethod method) { toReturn.method = method; TypeOracle oracle = method.getEnclosingType().getOracle(); JType returnType = method.getReturnType(); toReturn.isValueType = ModelUtils.isValueType(oracle, returnType); if (!toReturn.isValueType) { // See if it's a collection or a map JClassType returnClass = returnType.isClassOrInterface(); JClassType collectionInterface = oracle.findType(Collection.class.getCanonicalName()); JClassType mapInterface = oracle.findType(Map.class.getCanonicalName()); if (collectionInterface.isAssignableFrom(returnClass)) { JClassType[] parameterizations = ModelUtils.findParameterizationOf( collectionInterface, returnClass); toReturn.elementType = parameterizations[0]; maybeProcessEnumType(toReturn.elementType); } else if (mapInterface.isAssignableFrom(returnClass)) { JClassType[] parameterizations = ModelUtils.findParameterizationOf( mapInterface, returnClass); toReturn.keyType = parameterizations[0]; toReturn.valueType = parameterizations[1]; maybeProcessEnumType(toReturn.keyType); maybeProcessEnumType(toReturn.valueType); } } else { maybeProcessEnumType(returnType); } }
public void setMethod(JMethod method) { toReturn.method = method; TypeOracle oracle = method.getEnclosingType().getOracle(); JType returnType = method.getReturnType(); toReturn.isValueType = ModelUtils.isValueType(oracle, returnType); if (!toReturn.isValueType) { // See if it's a collection or a map JClassType returnClass = returnType.isClassOrInterface(); JClassType collectionInterface = oracle.findType(Collection.class.getCanonicalName()); JClassType mapInterface = oracle.findType(Map.class.getCanonicalName()); if (collectionInterface.isAssignableFrom(returnClass)) { JClassType[] parameterizations = ModelUtils.findParameterizationOf( collectionInterface, returnClass); toReturn.elementType = parameterizations[0]; maybeProcessEnumType(toReturn.elementType); } else if (mapInterface.isAssignableFrom(returnClass)) { JClassType[] parameterizations = ModelUtils.findParameterizationOf( mapInterface, returnClass); toReturn.keyType = parameterizations[0]; toReturn.valueType = parameterizations[1]; maybeProcessEnumType(toReturn.keyType); maybeProcessEnumType(toReturn.valueType); } } else { maybeProcessEnumType(returnType); } }
public void setMethod(JMethod method) { toReturn.method = method; TypeOracle oracle = method.getEnclosingType().getOracle(); JType returnType = method.getReturnType(); toReturn.isValueType = ModelUtils.isValueType(oracle, returnType); if (!toReturn.isValueType) { // See if it's a collection or a map JClassType returnClass = returnType.isClassOrInterface(); JClassType collectionInterface = oracle.findType(Collection.class.getCanonicalName()); JClassType mapInterface = oracle.findType(Map.class.getCanonicalName()); if (collectionInterface.isAssignableFrom(returnClass)) { JClassType[] parameterizations = ModelUtils.findParameterizationOf( collectionInterface, returnClass); toReturn.elementType = parameterizations[0]; maybeProcessEnumType(toReturn.elementType); } else if (mapInterface.isAssignableFrom(returnClass)) { JClassType[] parameterizations = ModelUtils.findParameterizationOf( mapInterface, returnClass); toReturn.keyType = parameterizations[0]; toReturn.valueType = parameterizations[1]; maybeProcessEnumType(toReturn.keyType); maybeProcessEnumType(toReturn.valueType); } } else { maybeProcessEnumType(returnType); } }
JClassType[] parameters = ModelUtils.findParameterizationOf(driverType, intf); assert parameters.length == 2 : "Unexpected number of type parameters";
JClassType[] parameters = ModelUtils.findParameterizationOf(driverType, intf); assert parameters.length == 2 : "Unexpected number of type parameters";
ModelUtils.findParameterizationOf(entityProxyIdInterface, transportedClass)[0]; methodBuilder.setEntityType(getEntityProxyType(entityType)); } else if (collectionInterface.isAssignableFrom(transportedClass)) { ModelUtils.findParameterizationOf(collectionInterface, transportedClass)[0]; methodBuilder.setCollectionElementType(elementType); validateTransportableType(methodBuilder, elementType, requireObject); JClassType[] params = ModelUtils.findParameterizationOf(mapInterface, transportedClass); JClassType keyType = params[0]; JClassType valueType = params[1];
ModelUtils.findParameterizationOf(entityProxyIdInterface, transportedClass)[0]; methodBuilder.setEntityType(getEntityProxyType(entityType)); } else if (collectionInterface.isAssignableFrom(transportedClass)) { ModelUtils.findParameterizationOf(collectionInterface, transportedClass)[0]; methodBuilder.setCollectionElementType(elementType); validateTransportableType(methodBuilder, elementType, requireObject); JClassType[] params = ModelUtils.findParameterizationOf(mapInterface, transportedClass); JClassType keyType = params[0]; JClassType valueType = params[1];
ModelUtils.findParameterizationOf(instanceRequestInterface, requestReturnType); methodBuilder.setInstanceType(getEntityProxyType(params[0])); invocationReturnType = params[1]; } else if (requestInterface.isAssignableFrom(requestReturnType)) { JClassType[] params = ModelUtils.findParameterizationOf(requestInterface, requestReturnType); invocationReturnType = params[0];
ModelUtils.findParameterizationOf(instanceRequestInterface, requestReturnType); methodBuilder.setInstanceType(getEntityProxyType(params[0])); invocationReturnType = params[1]; } else if (requestInterface.isAssignableFrom(requestReturnType)) { JClassType[] params = ModelUtils.findParameterizationOf(requestInterface, requestReturnType); invocationReturnType = params[0];
JClassType beanType = ModelUtils.findParameterizationOf( autoBeanInterface, returnType)[0]; if (beanType.isInterface() == null) {
JClassType beanType = ModelUtils.findParameterizationOf( autoBeanInterface, returnType)[0]; if (beanType.isInterface() == null) {
JClassType beanType = ModelUtils.findParameterizationOf( autoBeanInterface, returnType)[0]; if (beanType.isInterface() == null) {