001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     bstefanescu
011 */
012package org.nuxeo.ecm.automation;
013
014/**
015 * An object that can adapt a given object instance to an object of another type A type adapter accepts only one type of
016 * objects and can produce only one type of object.
017 *
018 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
019 */
020public interface TypeAdapter {
021
022    /**
023     * Adapt the given object to an instance of the given target type. The input object cannot be null. Throws an
024     * exception if the object cannot be adapted.
025     *
026     * @param ctx
027     * @param objectToAdapt
028     * @throws TypeAdaptException when the object cannot be adapted
029     */
030    Object getAdaptedValue(OperationContext ctx, Object objectToAdapt) throws TypeAdaptException;
031
032}