Field getType - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Field getType method.

This code example shows how to use the following methods:getDeclaringClass, getName, getType
 
            try { 
 
                final Resources resources = application.getResources();
                final int id = getId(resources,annotation);
                final Class<?> t = field.getType();
 
                if (String.class.isAssignableFrom(t)) {
                    value = resources.getString(id);
                } else if (boolean.class.isAssignableFrom(t) || Boolean.class.isAssignableFrom(t)) {
                    value = resources.getBoolean(id);
                } else if (ColorStateList.class.isAssignableFrom(t)  ) {
                    value = resources.getColorStateList(id);
                } else if (int.class.isAssignableFrom(t) || Integer.class.isAssignableFrom(t)) {
                    value = resources.getInteger(id);
                } else if (Drawable.class.isAssignableFrom(t)) {
                    value = resources.getDrawable(id);
                } else if (String[].class.isAssignableFrom(t)) {
                    value = resources.getStringArray(id);
                } else if (int[].class.isAssignableFrom(t) || Integer[].class.isAssignableFrom(t)) {

8
CodeRank
This code example shows how to use the following methods:getType
        } 
        return null; 
    } 
 
    public static boolean isNumeric(Field field) {
        Class<?> type = field.getType();
        return Classes.isNumeric(type);
    } 
} 
7
CodeRank
This code example shows how to use the following methods:isAnnotationPresent, getAnnotation, getName, getType
    protected final String getValidJPAColumnName(Class<?> entity, Field f)
    { 
 
        String name = null;
 
        if (f.isAnnotationPresent(Column.class))
        { 
            Column c = f.getAnnotation(Column.class);
            if (!c.name().isEmpty())
            { 
                name = c.name();
            } 
            else 
            { 
                name = f.getName();
            } 
        } 
        else if (f.isAnnotationPresent(Basic.class))
        { 
            name = f.getName();

7
CodeRank
This code example shows how to use the following methods:getName, getType
/** 
 * Instantiate {@link ArgumentCaptor} a field annotated by &#64;Captor. 
 */ 
public class CaptorAnnotationProcessor implements FieldAnnotationProcessor<Captor> { 
    public Object process(Captor annotation, Field field) {
        Class<?> type = field.getType();
        if (!ArgumentCaptor.class.isAssignableFrom(type)) {
            throw new MockitoException("@Captor field must be of the type ArgumentCaptor.\n" + "Field: '" 
               + field.getName() + "' has wrong type\n"
               + "For info how to use @Captor annotations see examples in javadoc for MockitoAnnotations class."); 
        } 
        Class cls = new GenericMaster().getGenericType(field);
        return ArgumentCaptor.forClass(cls);
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getGenericType, getType
   * @param p 
   *          Field to examine 
   * @return The Class<?> of generic type if any, otherwise null 
   */ 
  public static Class<?> getGenericMultivalueType(final Field p) {
    if (p.getType() instanceof Class<?>) {
      final Type genericType = p.getGenericType();
      if (genericType != null && genericType instanceof ParameterizedType) {
        final ParameterizedType pt = (ParameterizedType) genericType;
        if (pt.getActualTypeArguments() != null && pt.getActualTypeArguments().length > 0) {
          if (((Class<?>) pt.getRawType()).isAssignableFrom(Map.class)) {
            if (pt.getActualTypeArguments()[1] instanceof Class<?>) {
              return (Class<?>) pt.getActualTypeArguments()[1];
            } else if (pt.getActualTypeArguments()[1] instanceof ParameterizedType)
              return (Class<?>) ((ParameterizedType) pt.getActualTypeArguments()[1]).getRawType();
          } else if (pt.getActualTypeArguments()[0] instanceof Class<?>) {
            return (Class<?>) pt.getActualTypeArguments()[0];
          } else if (pt.getActualTypeArguments()[0] instanceof ParameterizedType)
            return (Class<?>) ((ParameterizedType) pt.getActualTypeArguments()[0]).getRawType();
        } 

7
CodeRank
This code example shows how to use the following methods:getAnnotations, getType
	 * Create a new type descriptor from a {@link Field}. 
	 * <p>Use this constructor when a source or target conversion point is a field. 
	 * @param field the field 
	 */ 
	public TypeDescriptor(Field field) {
		Assert.notNull(field, "Field must not be null");
		this.resolvableType = ResolvableType.forField(field);
		this.type = this.resolvableType.resolve(field.getType());
		this.annotations = nullSafeAnnotations(field.getAnnotations());
	} 
 
	/** 
	 * Create a new type descriptor from a {@link Property}. 
	 * <p>Use this constructor when a source or target conversion point is a 
	 * property on a Java class. 
	 * @param property the property 
	 */ 
	public TypeDescriptor(Property property) {
		Assert.notNull(property, "Property must not be null");
		this.resolvableType = ResolvableType.forMethodParameter(property.getMethodParameter());
7
CodeRank
This code example shows how to use the following methods:getGenericType, getType
 
  public OUserObject2RecordHandler getObj2RecHandler() { 
    return obj2RecHandler;
  } 
 
  public OEntityManager getEntityManager() { 
    return entityManager;
  } 
 
  public boolean isLazyLoading() { 
    return lazyLoading;
  } 
 
  public String getFetchPlan() {
    return fetchPlan;
  } 
 
  public boolean fetchEmbeddedDocuments() { 
    return true; 
  } 

7
CodeRank
This code example shows how to use the following methods:isAnnotationPresent, getAnnotation, getType
		} 
	} 
 
	private IProxyTargetLocator getProxyTargetLocator(Field field)
	{ 
		if (field.isAnnotationPresent(EJB.class))
		{ 
			return new JavaEEBeanLocator(field.getAnnotation(EJB.class).name(), field.getType(),
				namingStrategy);
		} 
 
		if (field.isAnnotationPresent(PersistenceUnit.class))
		{ 
			return new EntityManagerFactoryLocator(field.getAnnotation(PersistenceUnit.class)
				.unitName()); 
		} 
 
		if (field.isAnnotationPresent(Resource.class))
		{ 
			return new JndiObjectLocator(field.getAnnotation(Resource.class).name(),

7
CodeRank
This code example shows how to use the following methods:isAnnotationPresent, getAnnotation, getName, getType
     */ 
    private final String getValidJPAColumnName()
    { 
 
        String name = null;
        if (member.isAnnotationPresent(Column.class))
        { 
            Column c = member.getAnnotation(Column.class);
            if (!c.name().isEmpty())
            { 
                name = c.name();
            } 
 
        } 
        if (member.isAnnotationPresent(Temporal.class))
        { 
            if (!member.getType().equals(Date.class))
            { 
                log.error("@Temporal must map to java.util.Date for @Entity(" + managedType.getJavaType() + "."
                        + member.getName() + ")");

7
CodeRank
This code example shows how to use the following methods:isAccessible, setAccessible, get, getType, set
        try 
        { 
            embeddedField = obj.getClass().getDeclaredField(fieldName);
            if (embeddedField != null)
            { 
                if (!embeddedField.isAccessible())
                { 
                    embeddedField.setAccessible(true);
                } 
                Object embededObject = embeddedField.get(obj);
                if (embededObject == null) 
                { 
                    Class embeddedObjectClass = embeddedField.getType();
                    if (Collection.class.isAssignableFrom(embeddedObjectClass))
                    { 
                        if (embeddedObjectClass.equals(List.class))
                        { 
                            return new ArrayList();
                        } 
                        else if (embeddedObjectClass.equals(Set.class))

7
CodeRank

Related Field getType Questions & Answers:

getType Method Overview
Returns a Class object that identifies the declared type for the field represented by this Field object.
See Code Examples for other Java 8 Field Methods: