/******************************************************************************* * 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 java.lang.reflect.Field; import org.openlegacy.EntitiesRegistry; import org.openlegacy.loaders.FieldLoader; import org.openlegacy.terminal.definitions.ScreenPartEntityDefinition; import org.openlegacy.terminal.services.ScreenEntitiesRegistry; import org.springframework.stereotype.Component; @Component public class ScreenPartFieldsLoader implements FieldLoader { @SuppressWarnings("rawtypes") public boolean match(EntitiesRegistry entitiesRegistry, Field field) { ScreenEntitiesRegistry screenEntitiesRegistry = (ScreenEntitiesRegistry)entitiesRegistry; return (screenEntitiesRegistry.getPart(field.getType()) != null); } @SuppressWarnings("rawtypes") public void load(EntitiesRegistry entitiesRegistry, Field field, Class<?> containingClass) { ScreenEntitiesRegistry screenEntitiesRegistry = (ScreenEntitiesRegistry)entitiesRegistry; ScreenPartEntityDefinition partDefinition = screenEntitiesRegistry.getPart(field.getType()); if (partDefinition != null) { screenEntitiesRegistry.get(containingClass).getPartsDefinitions().put(field.getName(), partDefinition); } } }