001/* 002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Vladimir Pasquier <[email protected]> 018 */ 019package org.nuxeo.ecm.automation.context; 020 021import org.nuxeo.common.xmap.annotation.XNode; 022import org.nuxeo.common.xmap.annotation.XObject; 023 024/** 025 * @since 7.3 026 */ 027@XObject("contextHelper") 028public class ContextHelperDescriptor { 029 030 @XNode("@id") 031 protected String id; 032 033 protected ContextHelper contextHelper; 034 035 @XNode("@class") 036 public void setClass(Class<? extends ContextHelper> aType) throws InstantiationException, IllegalAccessException { 037 contextHelper = aType.newInstance(); 038 } 039 040 @XNode("@enabled") 041 protected boolean enabled = true; 042 043 public ContextHelper getContextHelper() { 044 return contextHelper; 045 } 046 047 public boolean isEnabled() { 048 return enabled; 049 } 050 051 public String getId() { 052 return id; 053 } 054 055 public ContextHelperDescriptor clone() { 056 ContextHelperDescriptor copy = new ContextHelperDescriptor(); 057 copy.id = id; 058 copy.contextHelper = contextHelper; 059 copy.enabled = enabled; 060 return copy; 061 } 062 063 public void merge(ContextHelperDescriptor src) { 064 if (src.contextHelper != null) { 065 contextHelper = src.contextHelper; 066 } 067 enabled = src.enabled; 068 } 069 070}