List of usage examples for java.lang.reflect Field getType
public Class<?> getType()
From source file:egov.data.ibatis.repository.support.SqlMapRepositoryFactory.java
private Field findSqlMapExecutorDelegate(SqlMapClient sqlMapClient) { Class<?> searchType = sqlMapClient.getClass(); while (!Object.class.equals(searchType) && searchType != null) { Field[] fields = searchType.getDeclaredFields(); for (Field field : fields) { if (SqlMapExecutorDelegate.class.isAssignableFrom(field.getType())) return field; }/*from w ww .ja va 2s . c o m*/ searchType = searchType.getSuperclass(); } return null; }
From source file:it.unibas.spicy.persistence.object.operators.AnalyzeFields.java
private boolean isPrimitiveType(Field field) { return field.getType().isPrimitive(); }
From source file:org.jongo.marshall.jackson.JacksonIdFieldSelector.java
public boolean isObjectId(Field f) { return f.isAnnotationPresent(org.jongo.marshall.jackson.oid.ObjectId.class) || f.isAnnotationPresent(MongoObjectId.class) || ObjectId.class.isAssignableFrom(f.getType()); }
From source file:net.eledge.android.toolkit.db.internal.TableBuilder.java
private String createFieldDef(Class<?> clazz, Field field) { FieldType type = FieldType.getType(field.getType()); Column column = field.getAnnotation(Column.class); if (StringUtils.isNotEmpty(column.columnDefinition())) { return column.columnDefinition(); }/* w w w. j a va2 s .c om*/ StringBuilder sb = new StringBuilder(); sb.append(SQLBuilder.getFieldName(field, column)); sb.append(" ").append(type.columnType); if (column.unique()) { sb.append(" UNIQUE"); } try { if (!column.nullable()) { sb.append(" NOT NULL"); sb.append(" DEFAULT ").append(type.defaultValue(clazz.newInstance(), field)); } } catch (Exception e) { Log.e(this.getClass().getName(), e.getMessage(), e); } if (field.isAnnotationPresent(Id.class)) { sb.append(" PRIMARY KEY"); } return sb.toString(); }
From source file:elaborate.tag_analysis.oosm.impl.gson.BaseInterfaceDeserializer.java
protected Object processNormalElement(String name, JsonElement element, Field field, JsonDeserializationContext jdc) throws JsonParseException { return this.processNormalElement(name, element, field.getType(), jdc); }
From source file:eu.codesketch.scriba.rest.analyser.domain.service.introspector.jackson.JsonPropertyAnnotationIntrospector.java
private Property extractProperty(Descriptor descriptor) { JsonProperty jsonProperty = descriptor.getWrappedAnnotationAs(JsonProperty.class); String propertyName = jsonProperty.value(); Class<?> parameterType; Field field = descriptor.annotatedElementAs(Field.class); if (null != field) { parameterType = field.getType(); propertyName = "".equals(propertyName) ? field.getName() : propertyName; } else {//from w w w .ja v a 2 s . c o m Method method = descriptor.annotatedElementAs(Method.class); if (isSetter(method)) { parameterType = method.getParameterTypes()[0]; } else { parameterType = method.getReturnType(); } propertyName = "".equals(propertyName) ? getPropertyNamefromSetterOrGetter(method.getName()) : propertyName; } LOGGER.debug("JsonProperty annotation has defined property name {}", propertyName); if (!isPrimitiveOrWrapper(parameterType)) { Property property = new Property(null, propertyName); for (Descriptor innerDescriptor : getDescriptorsForAnnotation(parameterType, JsonProperty.class)) { property.addProperty(extractProperty(innerDescriptor)); } return property; } else { return new Property(parameterType.getName(), propertyName); } }
From source file:it.unibas.spicy.persistence.object.operators.AnalyzeFields.java
private boolean isWrapperType(Field field) { Class type = field.getType(); if (type.equals(java.lang.String.class) || type.equals(java.lang.Integer.class) || type.equals(java.lang.Double.class) || type.equals(java.lang.Float.class) || type.equals(java.lang.Boolean.class) || type.equals(java.lang.Character.class)) { return true; }//from w w w . j a va 2 s . c om return false; }
From source file:in.hatimi.nosh.support.CmdLineManager.java
private boolean injectBoolean(Object target, Field field, Boolean value) { if (field.getType().equals(Boolean.class) || field.getType().equals(Boolean.TYPE)) { return injectImpl(target, field, value); }/*from w w w. java2s.c om*/ return false; }
From source file:com.ngandroid.lib.NgAndroid.java
public <T> T buildScope(Class<T> clss) { T instance;/*w w w . j ava 2 s .com*/ try { instance = clss.newInstance(); Field[] fields = clss.getDeclaredFields(); for (Field f : fields) { f.setAccessible(true); Class type = f.getType(); if (type.isInterface() && !f.isAnnotationPresent(Ignore.class)) { f.set(instance, buildModel(type)); } } } catch (InstantiationException | IllegalAccessException e) { // TODO throw new RuntimeException("Error instantiating scope.", e); } return instance; }
From source file:in.hatimi.nosh.support.CmdLineManager.java
private boolean injectStringArray(Object target, Field field, String[] values) { if (!field.getType().isAssignableFrom(String[].class)) { return false; }/* w w w. j av a 2s.c o m*/ return injectImpl(target, field, values); }