Tabnine Logo
RebindUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
RebindUtils
in
sk.seges.acris.core.rebind

Best Java code snippets using sk.seges.acris.core.rebind.RebindUtils (Showing top 16 results out of 315)

origin: sk.seges.acris/acris-client-core

public static JMethod getGetter(JClassType beanType, String fieldName) throws NotFoundException {
  JMethod method = null;
  try {
    try {
      method = beanType.getMethod("get" + getterSetterDeterminator(fieldName), new JType[0]);
    } catch (NotFoundException e) {
      method = beanType.getMethod("is" + getterSetterDeterminator(fieldName), new JType[0]);
    }
  } catch (NotFoundException e) {
    JClassType superClass = beanType.getSuperclass();
    if (superClass != null) {
      try {
        method = getGetter(superClass, fieldName);
      } catch (NotFoundException e1) {
        JClassType[] interfaces = beanType.getImplementedInterfaces();
        if (interfaces != null && interfaces.length > 0) {
          for (JClassType intrface : interfaces) {
            method = getGetter(intrface, fieldName);
            if (method != null) {
              break;
            }
          }
        }
      }
    }
  }
  return method;
}
origin: sk.seges.acris/acris-client-core

/**
 * Will it comment later :)
 * 
 * @throws NotFoundException
 */
public static JClassType getDeclaredFieldClassType(JClassType classType, String property)
    throws NotFoundException {
  JType fieldType = getDeclaredFieldType(classType, property);
  if (fieldType instanceof JClassType) {
    return ((JClassType) fieldType);
  }
  return null;
}
origin: sk.seges.acris/acris-client-core

/**
 * Tries to find parametrized type in interface of a class.
 * 
 * @param classType
 *            A class having parametrized interface.
 * @param parametrizedType
 *            Interface where parametrized type is present.
 * @param position
 *            Position in a list of parametrized types in interface.
 * @return Generics type in interface implemented by a class type.
 * @throws NotFoundException
 */
public static JClassType getGenericsFromInterfaceType(JClassType classType, JClassType parametrizedType,
    int position) throws NotFoundException {
  JClassType type = getGenericsFromInterfaceHierarchy(classType, parametrizedType, position);
  if (type != null)
    return type;
  if (classType.getSuperclass() != null) {
    return getGenericsFromInterfaceType(classType.getSuperclass(), parametrizedType, position);
  }
  throw new NotFoundException("Unable to find generics in type " + classType
      + ", where parametrized type is " + parametrizedType + " on position " + position);
}
origin: sk.seges.acris/acris-client-core

public static JMethod getSetter(JClassType beanType, String fieldName, JType fieldType)
    throws NotFoundException {
  JMethod method = null;
  try {
    method = beanType.getMethod("set" + getterSetterDeterminator(fieldName),
        new JType[] { fieldType });
    if (method.isPrivate())
      method = null;
  } catch (NotFoundException e) {
    JClassType superClass = beanType.getSuperclass();
    if (superClass != null) {
      try {
        method = getSetter(superClass, fieldName, fieldType);
      } catch (NotFoundException e1) {
        JClassType[] interfaces = beanType.getImplementedInterfaces();
        if (interfaces != null && interfaces.length > 0) {
          for (JClassType intrface : interfaces) {
            method = getSetter(intrface, fieldName, fieldType);
            if (method != null) {
              break;
            }
          }
        }
      }
    }
  }
  return method;
}
origin: sk.seges.acris/acris-widgets-beantable

    field = directField;
    fieldType = RebindUtils.getDeclaredFieldType(beanType, specColumn.field());
  } else {
    fieldType = RebindUtils.getDeclaredFieldType(beanType, field);
JMethod setter = null;
try {
  getter = RebindUtils.getGetter(beanType, field);
  setter = RebindUtils.getSetter(beanType, field, fieldType);
} catch (NotFoundException e) {
  throw new RuntimeException("Unable to retrieve getter for field = " + field, e);
  String propertyFieldGetter = null;
  try {
    propertyFieldGetter = RebindUtils.getGetterForMoreDotsInBeanTable(beanType, specColumn
        .field());
  } catch (NotFoundException e) {
origin: sk.seges.acris/acris-client-core

/**
 * recursively calls {@link RebindUtils#getGetter(JClassType, String)} to
 * handle "more-dots strings"<br />
 * e.g.: address.street returns getAddress().getStreet
 * 
 * @param beanType
 * @param fieldName
 * @return string - chain of getter methods
 * @throws NotFoundException
 */
public static String getGetterForMoreDotsInBeanTable(JClassType beanType, String fieldName)
    throws NotFoundException {
  JMethod method = null;
  int dotIndex = fieldName.indexOf(".");
  if (dotIndex == -1) {
    method = getGetter(beanType, fieldName);
    if (method == null)
      throw new NotFoundException();
    return method.getName();
  } else {
    method = getGetter(beanType, fieldName.substring(0, dotIndex));
    return method.getName()
        + "()."
        + getGetterForMoreDotsInBeanTable(method.getReturnType().isClass(), fieldName
            .substring(dotIndex + 1));
  }
}
origin: sk.seges.acris/acris-client-core

/**
 * Searches class and all its superclasses for a field.
 * 
 * @param classType
 * @param fieldName
 * @return field or method containing representing the field
 * @throws NotFoundException
 */
public static Object getDeclaredDirectField(JClassType classType, String fieldName)
    throws NotFoundException {
  JField field = classType.getField(fieldName);
  JClassType superClass = classType.getSuperclass();
  JMethod getter = null;
  if (field == null) {
    try {
      getter = getGetter(classType, fieldName);
    } catch (Exception e) {}
  }
  if (field == null && getter == null && superClass != null) {
    return getDeclaredDirectField(superClass, fieldName);
  }
  if (field != null) {
    return field;
  } else if (getter != null) {
    return getter;
  }
  throw new NotFoundException(
      "Unable to identify a property descriptor (field or method) for classType = " + classType
          + ", field = " + fieldName);
}
origin: sk.seges.acris/acris-binding

String fieldName = RebindUtils.toFieldName(beanMethod.getName());
  JMethod getter = RebindUtils.getGetter(classType, fieldName);
  if (getter == null) {
origin: sk.seges.acris/acris-binding

@Override
public String doGenerate(TreeLogger logger, GeneratorContext context, String typeClass)
    throws UnableToCompleteException {
  this.logger = logger;
  this.context = context;
  typeOracle = context.getTypeOracle();
  type = typeOracle.findType(typeClass);
  JClassType beanWrapperType = typeOracle.findType(BEAN_WRAPPER_FQN);
  JClassType[] directImplementors = beanWrapperType.getSubtypes();
  List<JClassType> beanList = new ArrayList<JClassType>();
  for (JClassType wrapper : directImplementors) {
    try {
      beanList.add(RebindUtils.getGenericsFromInterfaceType(wrapper, beanWrapperType, 0));
    } catch (NotFoundException e) {
      logger.log(Type.WARN, "Skipping wrapper = " + wrapper
          + " because cannot get generics argument");
    }
  }
  String packageName = type.getPackage().getName();
  String genTypeName = type.getSimpleSourceName() + "Generated";
  String fqn = packageName + "." + genTypeName;
  SourceWriter sourceWriter = getSourceWriter(packageName, genTypeName, type);
  if (sourceWriter == null) {
    return fqn;
  }
  BeanPropertyDescriptorCreator creator = new BeanPropertyDescriptorCreator();
  creator.write(logger, sourceWriter, beanList);
  sourceWriter.commit(logger);
  return fqn;
}
origin: sk.seges.acris/acris-client-core

return getGenericsFromSuperclassType(superclassType/*
origin: sk.seges.acris/acris-client-core

int dotIndex = property.indexOf(".");
if (dotIndex == -1) {
  return getDeclaredDirectField(classType, property);
} else {
  Object propertyRepresentation = getDeclaredDirectField(classType, property.substring(0, dotIndex));
  JClassType propertyType;
  if (propertyRepresentation instanceof JField) {
        + ", property = " + property);
  return getDeclaredField(propertyType, property.substring(dotIndex + 1));
origin: sk.seges.acris/acris-client-core

/**
 * Will it comment it aprox. 2 minutes before getDeclaredFieldClassType
 * method
 * 
 * @throws NotFoundException
 */
public static JType getDeclaredFieldType(JClassType classType, String property) throws NotFoundException {
  Object propertyRepresentation = RebindUtils.getDeclaredField(classType, property);
  if (propertyRepresentation == null) {
    return null;
  }
  if (propertyRepresentation instanceof JField) {
    return ((JField) propertyRepresentation).getType();
  } else if (propertyRepresentation instanceof JMethod) {
    return ((JMethod) propertyRepresentation).getReturnType();
  } else {
    throw new NotFoundException("Unsupported property type = "
        + propertyRepresentation.getClass().getName() + ", classType = " + classType
        + ", property = " + property);
  }
}
origin: sk.seges.acris/acris-binding

if (RebindUtils.getComparableMethodDeclaration(allMethod).compareTo(RebindUtils.getComparableMethodDeclaration(method)) == 0) {
  found = true;
origin: sk.seges.acris/acris-binding

@Override
protected boolean initialize() throws UnableToCompleteException {
  try {
    bindingBeanClassType = RebindUtils.getGenericsFromInterfaceType(classType, typeOracle
        .findType(IBeanBindingHolder.class.getName()), 0);
  } catch (NotFoundException e) {
    logger.log(Type.ERROR, "Unable to extract generic type class from interface");
    throw new UnableToCompleteException();
  }
  // initialize binding context for all related creators
  BindingCreatorFactory.setBindingContext(bindingBeanClassType, packageName, namingStrategy);
  BindingFieldsBase bindingFieldsBaseAnnotation = classType.getAnnotation(BindingFieldsBase.class);
  if (bindingFieldsBaseAnnotation == null) {
    return false;
  }
  validationEnabled = isValidationEnabled(bindingFieldsBaseAnnotation);
  setDefaultLoaderCreator();
  try {
    BindingCreatorFactory.fillSupportedTypes(context.getTypeOracle());
  } catch (GeneratorException e) {
    logger.log(Type.ERROR, e.getMessage());
    throw new UnableToCompleteException();
  }
  return true;
}
origin: sk.seges.acris/acris-binding

widgetClassType = RebindUtils.getGenericsFromSuperclassType(classType, 0);
origin: sk.seges.acris/acris-client-core

String setterName = "set" + getterSetterDeterminator(fieldName);
  fd.getterMethod = getGetter(beanType, fieldName);
} catch (NotFoundException e) {
sk.seges.acris.core.rebindRebindUtils

Most used methods

  • getGetter
  • getDeclaredFieldType
    Will it comment it aprox. 2 minutes before getDeclaredFieldClassType method
  • getGenericsFromInterfaceType
    Tries to find parametrized type in interface of a class.
  • getGenericsFromSuperclassType
    Same as getGenericsFromInterfaceType but it extracts generics from superclass
  • getGetterForMoreDotsInBeanTable
    recursively calls RebindUtils#getGetter(JClassType,String) to handle "more-dots strings" e.g.: addre
  • getSetter
  • getComparableMethodDeclaration
  • getDeclaredDirectField
    Searches class and all its superclasses for a field.
  • getDeclaredField
    Searches class and all its superclasses for a property.
  • getDeclaredFieldClassType
    Will it comment later :)
  • getGenericsFromInterfaceHierarchy
    Tries to find parametrized type in interface hierarchy of a class.
  • getterSetterDeterminator
    Example: for field street it will generate string Street used to construct getter/setter.
  • getGenericsFromInterfaceHierarchy,
  • getterSetterDeterminator,
  • toFieldName

Popular in Java

  • Making http post requests using okhttp
  • addToBackStack (FragmentTransaction)
  • getExternalFilesDir (Context)
  • onCreateOptionsMenu (Activity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now