/******************************************************************************* * Copyright (c) 2012 OpenLegacy Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * OpenLegacy Inc. - initial API and implementation *******************************************************************************/ package org.openlegacy.loaders.support; import org.openlegacy.EntitiesRegistry; import org.openlegacy.loaders.FieldLoader; import org.openlegacy.terminal.definitions.ScreenTableDefinition; import org.openlegacy.terminal.services.ScreenEntitiesRegistry; import org.openlegacy.utils.ReflectionUtil; import org.springframework.stereotype.Component; import java.lang.reflect.Field; @Component public class TableFieldsLoader implements FieldLoader { @SuppressWarnings("rawtypes") public boolean match(EntitiesRegistry entitiesRegistry, Field field) { ScreenEntitiesRegistry screenEntitiesRegistry = (ScreenEntitiesRegistry)entitiesRegistry; Class<?> listType = ReflectionUtil.getListType(field); if (listType == null) { return false; } return (screenEntitiesRegistry.getTable(listType) != null); } @SuppressWarnings("rawtypes") public void load(EntitiesRegistry entitiesRegistry, Field field, Class<?> containingClass) { ScreenEntitiesRegistry screenEntitiesRegistry = (ScreenEntitiesRegistry)entitiesRegistry; Class<?> listType = ReflectionUtil.getListType(field); ScreenTableDefinition tableDefinition = screenEntitiesRegistry.getTable(listType); if (tableDefinition != null) { screenEntitiesRegistry.get(containingClass).getTableDefinitions().put(field.getName(), tableDefinition); } } }