001/* 002 * Copyright c 2018 Rusi Popov, MDA Tools.net All rights reserved. 003 * 004 * This program and the accompanying materials are made available under the terms of the 005 * Eclipse Public License v2.0 which accompanies this distribution, and is available at 006 * http://www.eclipse.org/legal/epl-v20.html 007 */ 008package net.mdatools.modelant.core.operation.element; 009 010import javax.jmi.reflect.RefObject; 011 012import net.mdatools.modelant.core.api.Operation; 013 014/** 015 * Instantiate a the model element's class. 016 * @author Rusi Popov (popovr@mdatools.net) 017 */ 018public class ConstructSame implements Operation<RefObject> { 019 020 /** 021 * @param source Navigate from this element, down the path 022 */ 023 public RefObject execute(RefObject source) throws IllegalArgumentException { 024 RefObject result; 025 026 // fond the source object 027 if ( source == null ) { 028 throw new IllegalArgumentException("Expected a non-null model element"); 029 } 030 031 // find the target extent 032 result = source.refClass().refCreateInstance( null ); 033 034 return result; 035 } 036}