org.cruxframework.crux.core.utils
Class JClassUtils

java.lang.Object
  extended by org.cruxframework.crux.core.utils.JClassUtils

public class JClassUtils
extends Object

Author:
Thiago da Rosa de Bustamante

Nested Class Summary
static class JClassUtils.PropertyInfo
           
 
Constructor Summary
JClassUtils()
           
 
Method Summary
static com.google.gwt.core.ext.typeinfo.JType buildGetValueExpression(StringBuilder out, com.google.gwt.core.ext.typeinfo.JClassType dtoType, String propertyPath, String objectVariable, boolean finishCommand)
           
static com.google.gwt.core.ext.typeinfo.JType buildSetValueExpression(AbstractProxyCreator.SourcePrinter out, com.google.gwt.core.ext.typeinfo.JClassType dtoType, String propertyPath, String objectVariable, String value)
           
static JClassUtils.PropertyInfo[] extractBeanPropertiesInfo(com.google.gwt.core.ext.typeinfo.JClassType type)
           
static com.google.gwt.core.ext.typeinfo.JMethod[] findMethods(com.google.gwt.core.ext.typeinfo.JClassType clazz, String methodName)
           
static com.google.gwt.core.ext.typeinfo.JMethod[] findSetterMethods(com.google.gwt.core.ext.typeinfo.JClassType clazz, String propertyName)
           
static void generateFieldValueSet(com.google.gwt.core.ext.typeinfo.JClassType voClass, com.google.gwt.core.ext.typeinfo.JField field, String parentVariable, String valueVariable, AbstractProxyCreator.SourcePrinter sourceWriter, boolean allowProtected)
          Generates a property set block.
static com.google.gwt.core.ext.typeinfo.JClassType[] getActualParameterTypes(com.google.gwt.core.ext.typeinfo.JClassType baseType, com.google.gwt.core.ext.typeinfo.JClassType desiredInterfaceType)
           
static com.google.gwt.core.ext.typeinfo.JField getDeclaredField(com.google.gwt.core.ext.typeinfo.JClassType clazz, String name)
           
static com.google.gwt.core.ext.typeinfo.JField[] getDeclaredFields(com.google.gwt.core.ext.typeinfo.JClassType clazz)
           
static String getEmptyValueForType(com.google.gwt.core.ext.typeinfo.JType objectType)
           
static com.google.gwt.core.ext.typeinfo.JField getField(com.google.gwt.core.ext.typeinfo.JClassType clazz, String fieldName)
          Retrieve a field from class.
static String getFieldValueGet(com.google.gwt.core.ext.typeinfo.JClassType voClass, com.google.gwt.core.ext.typeinfo.JField field, String parentVariable, boolean allowProtected)
          Deprecated. 
static String getFieldValueGet(com.google.gwt.core.ext.typeinfo.JClassType clazz, String propertyName, String parentVariable, boolean allowProtected)
          Generates a property get block.
static String getGenericDeclForType(com.google.gwt.core.ext.typeinfo.JType type)
          Returns a string to be used in generic code block, according with the given type
static String getGetterMethod(String propertyName, com.google.gwt.core.ext.typeinfo.JClassType baseClass)
           
static List<com.google.gwt.core.ext.typeinfo.JMethod> getGetterMethods(com.google.gwt.core.ext.typeinfo.JClassType objectType)
           
static com.google.gwt.core.ext.typeinfo.JMethod getMethod(com.google.gwt.core.ext.typeinfo.JClassType clazz, String methodName, com.google.gwt.core.ext.typeinfo.JType[] params)
           
static String getMethodDescription(com.google.gwt.core.ext.typeinfo.JMethod method)
           
static String getParsingExpressionForSimpleType(String valueVariable, com.google.gwt.core.ext.typeinfo.JType expectedType)
           
static String getPropertyForGetterOrSetterMethod(com.google.gwt.core.ext.typeinfo.JMethod method)
           
static com.google.gwt.core.ext.typeinfo.JType getPropertyType(com.google.gwt.core.ext.typeinfo.JClassType clazz, String propertyName)
          Retrieve the property type on the given class
static com.google.gwt.core.ext.typeinfo.JType getReturnTypeFromMethodClass(com.google.gwt.core.ext.typeinfo.JClassType clazz, String methodName, com.google.gwt.core.ext.typeinfo.JType[] params)
           
static String getSetterMethod(String propertyName, com.google.gwt.core.ext.typeinfo.JClassType baseClass, com.google.gwt.core.ext.typeinfo.JType propertyType)
           
static List<com.google.gwt.core.ext.typeinfo.JMethod> getSetterMethods(com.google.gwt.core.ext.typeinfo.JClassType objectType)
           
static com.google.gwt.core.ext.typeinfo.JClassType getType(com.google.gwt.core.ext.typeinfo.TypeOracle typeOracle, String className)
           
static com.google.gwt.core.ext.typeinfo.JClassType getType(com.google.gwt.core.ext.typeinfo.TypeOracle typeOracle, String className, String viewName)
           
static com.google.gwt.core.ext.typeinfo.JClassType getTypeArgForGenericType(com.google.gwt.core.ext.typeinfo.JClassType type)
           
static com.google.gwt.core.ext.typeinfo.JType getTypeForProperty(String property, com.google.gwt.core.ext.typeinfo.JClassType objectType)
           
static boolean hasGetAndSetMethods(com.google.gwt.core.ext.typeinfo.JField field, com.google.gwt.core.ext.typeinfo.JClassType clazz)
          Returns true is the given field has both a "get" and a "set" methods.
static boolean hasGetMethod(com.google.gwt.core.ext.typeinfo.JField field, com.google.gwt.core.ext.typeinfo.JClassType clazz)
          Returns true is the given field has an associated public "get" method.
static boolean hasSetMethod(com.google.gwt.core.ext.typeinfo.JField field, com.google.gwt.core.ext.typeinfo.JClassType clazz)
          Returns true is the given field has an associated public "set" method.
static boolean isFullAccessibleField(com.google.gwt.core.ext.typeinfo.JField field, com.google.gwt.core.ext.typeinfo.JClassType clazz)
          Verify if the given field is fully accessible.
static boolean isPropertyVisibleToRead(com.google.gwt.core.ext.typeinfo.JClassType voClass, com.google.gwt.core.ext.typeinfo.JField field, boolean allowProtected)
          Verify if the given field is a visible property
static boolean isPropertyVisibleToWrite(com.google.gwt.core.ext.typeinfo.JClassType voClass, com.google.gwt.core.ext.typeinfo.JField field, boolean allowProtected)
          Verify if the given field is a visible property
static boolean isSimpleType(com.google.gwt.core.ext.typeinfo.JType type)
           
static boolean isValidGetterMethod(com.google.gwt.core.ext.typeinfo.JMethod method)
           
static boolean isValidSetterMethod(com.google.gwt.core.ext.typeinfo.JMethod method)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JClassUtils

public JClassUtils()
Method Detail

buildGetValueExpression

public static com.google.gwt.core.ext.typeinfo.JType buildGetValueExpression(StringBuilder out,
                                                                             com.google.gwt.core.ext.typeinfo.JClassType dtoType,
                                                                             String propertyPath,
                                                                             String objectVariable,
                                                                             boolean finishCommand)
                                                                      throws NoSuchFieldException
Throws:
NoSuchFieldException

getType

public static com.google.gwt.core.ext.typeinfo.JClassType getType(com.google.gwt.core.ext.typeinfo.TypeOracle typeOracle,
                                                                  String className)
                                                           throws com.google.gwt.core.ext.typeinfo.NotFoundException
Throws:
com.google.gwt.core.ext.typeinfo.NotFoundException

getType

public static com.google.gwt.core.ext.typeinfo.JClassType getType(com.google.gwt.core.ext.typeinfo.TypeOracle typeOracle,
                                                                  String className,
                                                                  String viewName)
                                                           throws com.google.gwt.core.ext.typeinfo.NotFoundException
Throws:
com.google.gwt.core.ext.typeinfo.NotFoundException

buildSetValueExpression

public static com.google.gwt.core.ext.typeinfo.JType buildSetValueExpression(AbstractProxyCreator.SourcePrinter out,
                                                                             com.google.gwt.core.ext.typeinfo.JClassType dtoType,
                                                                             String propertyPath,
                                                                             String objectVariable,
                                                                             String value)
                                                                      throws NoSuchFieldException
Throws:
NoSuchFieldException

getGetterMethod

public static String getGetterMethod(String propertyName,
                                     com.google.gwt.core.ext.typeinfo.JClassType baseClass)
Parameters:
propertyName -
baseClass -
Returns:

getSetterMethod

public static String getSetterMethod(String propertyName,
                                     com.google.gwt.core.ext.typeinfo.JClassType baseClass,
                                     com.google.gwt.core.ext.typeinfo.JType propertyType)
Parameters:
propertyName -
baseClass -
Returns:

getReturnTypeFromMethodClass

public static com.google.gwt.core.ext.typeinfo.JType getReturnTypeFromMethodClass(com.google.gwt.core.ext.typeinfo.JClassType clazz,
                                                                                  String methodName,
                                                                                  com.google.gwt.core.ext.typeinfo.JType[] params)
Parameters:
methodName -
Returns:

getMethod

public static com.google.gwt.core.ext.typeinfo.JMethod getMethod(com.google.gwt.core.ext.typeinfo.JClassType clazz,
                                                                 String methodName,
                                                                 com.google.gwt.core.ext.typeinfo.JType[] params)
Parameters:
clazz -
methodName -
params -
Returns:

getField

public static com.google.gwt.core.ext.typeinfo.JField getField(com.google.gwt.core.ext.typeinfo.JClassType clazz,
                                                               String fieldName)
Retrieve a field from class. Searches also into the class hierarchy

Parameters:
clazz - class to search the field
fieldName - field name
Returns:
the field

findMethods

public static com.google.gwt.core.ext.typeinfo.JMethod[] findMethods(com.google.gwt.core.ext.typeinfo.JClassType clazz,
                                                                     String methodName)
Parameters:
clazz -
methodName -
Returns:

findSetterMethods

public static com.google.gwt.core.ext.typeinfo.JMethod[] findSetterMethods(com.google.gwt.core.ext.typeinfo.JClassType clazz,
                                                                           String propertyName)
Parameters:
clazz -
propertyName -
Returns:

getParsingExpressionForSimpleType

public static String getParsingExpressionForSimpleType(String valueVariable,
                                                       com.google.gwt.core.ext.typeinfo.JType expectedType)
                                                throws com.google.gwt.core.ext.typeinfo.NotFoundException
Parameters:
valueVariable -
expectedType -
Returns:
Throws:
com.google.gwt.core.ext.typeinfo.NotFoundException

getDeclaredField

public static com.google.gwt.core.ext.typeinfo.JField getDeclaredField(com.google.gwt.core.ext.typeinfo.JClassType clazz,
                                                                       String name)
                                                                throws NoSuchFieldException
Parameters:
clazz -
name -
Returns:
Throws:
NoSuchFieldException

getDeclaredFields

public static com.google.gwt.core.ext.typeinfo.JField[] getDeclaredFields(com.google.gwt.core.ext.typeinfo.JClassType clazz)
Parameters:
clazz -
Returns:

getMethodDescription

public static String getMethodDescription(com.google.gwt.core.ext.typeinfo.JMethod method)
Parameters:
method -
Returns:

getGenericDeclForType

public static String getGenericDeclForType(com.google.gwt.core.ext.typeinfo.JType type)
Returns a string to be used in generic code block, according with the given type

Parameters:
type -
Returns:

isSimpleType

public static boolean isSimpleType(com.google.gwt.core.ext.typeinfo.JType type)
Parameters:
type -
Returns:

hasGetAndSetMethods

public static boolean hasGetAndSetMethods(com.google.gwt.core.ext.typeinfo.JField field,
                                          com.google.gwt.core.ext.typeinfo.JClassType clazz)
Returns true is the given field has both a "get" and a "set" methods.

Parameters:
clazz -
field -
Returns:

hasGetMethod

public static boolean hasGetMethod(com.google.gwt.core.ext.typeinfo.JField field,
                                   com.google.gwt.core.ext.typeinfo.JClassType clazz)
Returns true is the given field has an associated public "get" method.

Parameters:
clazz -
field -
Returns:

hasSetMethod

public static boolean hasSetMethod(com.google.gwt.core.ext.typeinfo.JField field,
                                   com.google.gwt.core.ext.typeinfo.JClassType clazz)
Returns true is the given field has an associated public "set" method.

Parameters:
field -
clazz -
Returns:

isFullAccessibleField

public static boolean isFullAccessibleField(com.google.gwt.core.ext.typeinfo.JField field,
                                            com.google.gwt.core.ext.typeinfo.JClassType clazz)
Verify if the given field is fully accessible.

Parameters:
field -
clazz -
Returns:
true if the field is public or has associated "get" and "set" methods.

isPropertyVisibleToRead

public static boolean isPropertyVisibleToRead(com.google.gwt.core.ext.typeinfo.JClassType voClass,
                                              com.google.gwt.core.ext.typeinfo.JField field,
                                              boolean allowProtected)
Verify if the given field is a visible property

Parameters:
voClass -
field -
allowProtected -
Returns:

isPropertyVisibleToWrite

public static boolean isPropertyVisibleToWrite(com.google.gwt.core.ext.typeinfo.JClassType voClass,
                                               com.google.gwt.core.ext.typeinfo.JField field,
                                               boolean allowProtected)
Verify if the given field is a visible property

Parameters:
voClass -
field -
allowProtected -
Returns:

generateFieldValueSet

public static void generateFieldValueSet(com.google.gwt.core.ext.typeinfo.JClassType voClass,
                                         com.google.gwt.core.ext.typeinfo.JField field,
                                         String parentVariable,
                                         String valueVariable,
                                         AbstractProxyCreator.SourcePrinter sourceWriter,
                                         boolean allowProtected)
Generates a property set block. First try to set the field directly, then try to use a javabean setter method.

Parameters:
logger -
voClass -
field -
parentVariable -
valueVariable -
sourceWriter -

getPropertyType

public static com.google.gwt.core.ext.typeinfo.JType getPropertyType(com.google.gwt.core.ext.typeinfo.JClassType clazz,
                                                                     String propertyName)
Retrieve the property type on the given class

Parameters:
clazz - base class
propertyName - property name
Returns:
property type or null, if property is not present

getFieldValueGet

public static String getFieldValueGet(com.google.gwt.core.ext.typeinfo.JClassType clazz,
                                      String propertyName,
                                      String parentVariable,
                                      boolean allowProtected)
Generates a property get block. First try to get the field directly, then try to use a javabean getter method.

Parameters:
clazz - class where the property will be searched.
propertyName - property name
parentVariable - the name of the parent variable to use in generated expression
allowProtected - if this expression allow protected fields and methods access
Returns:
an expression in the form <parentVar>.<propertyAccessor>

getFieldValueGet

@Deprecated
public static String getFieldValueGet(com.google.gwt.core.ext.typeinfo.JClassType voClass,
                                                 com.google.gwt.core.ext.typeinfo.JField field,
                                                 String parentVariable,
                                                 boolean allowProtected)
Deprecated. 

Generates a property get block. First try to get the field directly, then try to use a javabean getter method.

Parameters:
voClass -
field -
parentVariable -
allowProtected -

isValidSetterMethod

public static boolean isValidSetterMethod(com.google.gwt.core.ext.typeinfo.JMethod method)

isValidGetterMethod

public static boolean isValidGetterMethod(com.google.gwt.core.ext.typeinfo.JMethod method)

getPropertyForGetterOrSetterMethod

public static String getPropertyForGetterOrSetterMethod(com.google.gwt.core.ext.typeinfo.JMethod method)

getSetterMethods

public static List<com.google.gwt.core.ext.typeinfo.JMethod> getSetterMethods(com.google.gwt.core.ext.typeinfo.JClassType objectType)

getGetterMethods

public static List<com.google.gwt.core.ext.typeinfo.JMethod> getGetterMethods(com.google.gwt.core.ext.typeinfo.JClassType objectType)

extractBeanPropertiesInfo

public static JClassUtils.PropertyInfo[] extractBeanPropertiesInfo(com.google.gwt.core.ext.typeinfo.JClassType type)

getTypeForProperty

public static com.google.gwt.core.ext.typeinfo.JType getTypeForProperty(String property,
                                                                        com.google.gwt.core.ext.typeinfo.JClassType objectType)

getEmptyValueForType

public static String getEmptyValueForType(com.google.gwt.core.ext.typeinfo.JType objectType)

getTypeArgForGenericType

public static com.google.gwt.core.ext.typeinfo.JClassType getTypeArgForGenericType(com.google.gwt.core.ext.typeinfo.JClassType type)

getActualParameterTypes

public static com.google.gwt.core.ext.typeinfo.JClassType[] getActualParameterTypes(com.google.gwt.core.ext.typeinfo.JClassType baseType,
                                                                                    com.google.gwt.core.ext.typeinfo.JClassType desiredInterfaceType)


Copyright © 2014. All rights reserved.