List of usage examples for java.lang.reflect Field getType
public Class<?> getType()
From source file:com.khubla.cbean.serializer.impl.SimpleFieldSerializer.java
@Override public boolean applies(Field field) { final Class<?> clazz = field.getType(); return isWrapperType(clazz) || clazz.isPrimitive() || clazz.equals(String.class); }
From source file:stormy.pythian.core.description.OutputStreamDescriptionFactory.java
@SuppressWarnings("unchecked") public List<OutputStreamDescription> createOutputStreamDescriptions(Class<?> componentClass) { List<OutputStreamDescription> descriptions = new ArrayList<>(); Set<Field> fields = getAllFields(componentClass, withAnnotation(OutputStream.class)); for (Field field : fields) { if (field.getType() != Stream.class) { throw new IllegalArgumentException(OutputStream.class + " can only be applied to " + Stream.class); }//from w w w . j a v a 2s . com OutputStream annotation = field.getAnnotation(OutputStream.class); OutputStreamDescription description = createOutputStreamDescription(componentClass, annotation); descriptions.add(description); } return descriptions; }
From source file:com.khubla.cbean.serializer.impl.json.JSONArrayFieldSerializer.java
@Override public boolean applies(Field field) { return field.getType().isArray(); }
From source file:com.cognifide.slice.mapper.impl.processor.SliceReferenceFieldProcessor.java
@Override public boolean accepts(final Resource resource, final Field field) { Class<?> type = field.getType(); // additional checks of type for performance sake return type != String.class && !type.isPrimitive() && field.isAnnotationPresent(SliceReference.class); }
From source file:com.cassius.spring.assembly.test.common.process.MakeObjectProcessor.java
/** * Do process before.// ww w . j a va2 s . co m * * @param context the context * @param instance the instance * @param field the field * @throws Exception the exception */ @Override protected void doProcessBefore(ApplicationContext context, Object instance, Field field) throws Exception { Object fieldValue = field.getType().newInstance(); FieldWriter.newInstance(instance, field, fieldValue).write(); }
From source file:com.msc.facturierws.dao.specif.DAOSpecifGeneric.java
@Override protected Field[] getFields() { Field[] allFields = super.getFields(); Field[] allFieldsClean = new Field[allFields.length - 1]; int i = 0;/* w w w. j a va 2 s. com*/ for (Field f : allFields) { if (f.getType() == Token.class) { continue; } allFieldsClean[i++] = f; } return allFieldsClean; }
From source file:stormy.pythian.core.description.InputStreamDescriptionFactory.java
@SuppressWarnings("unchecked") public List<InputStreamDescription> createInputStreamDescriptions(Class<?> componentClass) { List<InputStreamDescription> inputStreamDescriptions = new ArrayList<>(); Set<Field> inputStreamFields = getAllFields(componentClass, withAnnotation(InputStream.class)); for (Field inputStreamField : inputStreamFields) { if (inputStreamField.getType() != Stream.class) { throw new IllegalArgumentException(InputStream.class + " can only be applied to " + Stream.class); }/*w w w.jav a2 s . c om*/ InputStreamDescription inputStreamDescription = createInputStreamDescription(componentClass, inputStreamField); inputStreamDescriptions.add(inputStreamDescription); } return inputStreamDescriptions; }
From source file:com.codenjoy.dojo.tetris.model.GameSetupRule.java
private Field findField(Class fieldType, Object target) { Field[] fields = target.getClass().getDeclaredFields(); for (Field field : fields) { if (field.getType().isAssignableFrom(fieldType)) { field.setAccessible(true);//from w w w.j a v a 2 s .c om return field; } } return null; }
From source file:com.cassius.spring.assembly.test.common.process.MakeObjectProcessor.java
/** * Need process before.// w w w . j a v a 2 s . c o m * * @param instance the instance * @param field the field * @return the boolean */ @Override protected boolean needProcessBefore(Object instance, Field field) { return field.isAnnotationPresent(MakeObject.class) && !field.getType().isPrimitive(); }
From source file:com.cassius.spring.assembly.test.common.process.MockObjectProcessor.java
/** * Do process before.// w w w . j ava2 s.c o m * * @param context the context * @param instance the instance * @param field the field * @throws Exception the exception */ @Override protected void doProcessBefore(ApplicationContext context, Object instance, Field field) throws Exception { Object fieldValue = Mockito.mock(field.getType()); FieldWriter.newInstance(instance, field, fieldValue).write(); }