001/*
002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *      Vladimir Pasquier <vpasquier@nuxeo.com>
016 */
017package org.nuxeo.ecm.automation.context;
018
019import org.nuxeo.common.xmap.annotation.XNode;
020import org.nuxeo.common.xmap.annotation.XObject;
021
022/**
023 * @since 7.3
024 */
025@XObject("contextHelper")
026public class ContextHelperDescriptor {
027
028    @XNode("@id")
029    protected String id;
030
031    protected ContextHelper contextHelper;
032
033    @XNode("@class")
034    public void setClass(Class<? extends ContextHelper> aType) throws InstantiationException, IllegalAccessException {
035        contextHelper = aType.newInstance();
036    }
037
038    @XNode("@enabled")
039    protected boolean enabled = true;
040
041    public ContextHelper getContextHelper() {
042        return contextHelper;
043    }
044
045    public boolean isEnabled() {
046        return enabled;
047    }
048
049    public String getId() {
050        return id;
051    }
052
053    public ContextHelperDescriptor clone() {
054        ContextHelperDescriptor copy = new ContextHelperDescriptor();
055        copy.id = id;
056        copy.contextHelper = contextHelper;
057        copy.enabled = enabled;
058        return copy;
059    }
060
061    public void merge(ContextHelperDescriptor src) {
062        if (src.contextHelper != null) {
063            contextHelper = src.contextHelper;
064        }
065        enabled = src.enabled;
066    }
067
068}