private Map<FieldMetadata<?, ?>, TypeHandler> getFieldHandlerMap(ClassMetadata<?, ?> type) { Map<FieldMetadata<?, ?>, TypeHandler> handlerMap = Maps.newHashMap(); for (FieldMetadata<?, ?> field : type.getFields()) { TypeHandler<?> handler = getHandlerFor(field.getField().getGenericType()); if (handler != null) { handlerMap.put(field, handler); } else { logger.info("Unsupported field: '{}.{}'", type.getUri(), field.getName()); } } return handlerMap; }
private List<ComponentFieldUri> determineAnimationPoolUris() { final List<ComponentFieldUri> animationSetUris = Lists.newArrayList(); for (ComponentMetadata<?> componentMetadata : componentLibrary.iterateComponentMetadata()) { SimpleUri uri = componentMetadata.getUri(); for (FieldMetadata<?, ?> fieldMetadata : componentMetadata.getFields()) { if (fieldMetadata.getType().isAssignableFrom(List.class)) { Type fieldType = fieldMetadata.getField().getGenericType(); if (fieldType instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) fieldType; Type[] typeArguments = parameterizedType.getActualTypeArguments(); if (typeArguments.length == 1) { Class<?> typeClass = ReflectionUtil.getClassOfType(typeArguments[0]); if (typeClass.isAssignableFrom(MeshAnimation.class)) { animationSetUris.add(new ComponentFieldUri(uri, fieldMetadata.getName())); } } } } } } return animationSetUris; }
Type contentType = ReflectionUtil.getTypeParameter(field.getField().getGenericType(), 0); if (contentType != null) { List<Object> result = Lists.newArrayList();
public Object getComponentField(ComponentFieldUri uri) { ComponentLibrary componentLibrary = CoreRegistry.get(EntitySystemLibrary.class).getComponentLibrary(); ComponentMetadata<? extends Component> metadata = componentLibrary.getMetadata(uri.getComponentUri()); if (metadata == null) { return null; } Component component = entity.getComponent(metadata.getType()); if (component == null) { return null; } FieldMetadata<?, ?> fieldMetadata = metadata.getField(uri.getFieldName()); if (fieldMetadata == null) { return null; } Field field = fieldMetadata.getField(); try { return field.get(component); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }