001/*
002 * (C) Copyright 2010 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 *     Anahide Tchertchian
018 */
019package org.nuxeo.ecm.platform.query.core;
020
021import java.io.Serializable;
022import java.util.HashMap;
023import java.util.Map;
024
025import org.nuxeo.common.xmap.annotation.XNode;
026import org.nuxeo.common.xmap.annotation.XNodeList;
027import org.nuxeo.common.xmap.annotation.XNodeMap;
028import org.nuxeo.common.xmap.annotation.XObject;
029
030/**
031 * @author Anahide Tchertchian
032 * @since 5.4
033 */
034@XObject("coreQueryPageProvider")
035public class ReferencePageProviderDescriptor implements Serializable {
036
037    private static final long serialVersionUID = 1L;
038
039    @XNode("@name")
040    String name;
041
042    @XNode("@enabled")
043    boolean enabled = true;
044
045    @XNodeMap(value = "property", key = "@name", type = HashMap.class, componentType = String.class)
046    Map<String, String> properties = new HashMap<String, String>();
047
048    @XNodeList(value = "parameter", type = String[].class, componentType = String.class)
049    String[] queryParameters;
050
051    public String getName() {
052        return name;
053    }
054
055    public boolean isEnabled() {
056        return enabled;
057    }
058
059    public Map<String, String> getProperties() {
060        return properties;
061    }
062
063    public String[] getQueryParameters() {
064        return queryParameters;
065    }
066
067    /**
068     * @since 5.6
069     */
070    @Override
071    public ReferencePageProviderDescriptor clone() {
072        ReferencePageProviderDescriptor clone = new ReferencePageProviderDescriptor();
073        clone.name = getName();
074        clone.enabled = isEnabled();
075        Map<String, String> props = getProperties();
076        if (props != null) {
077            clone.properties = new HashMap<String, String>();
078            clone.properties.putAll(props);
079        }
080        String[] params = getQueryParameters();
081        if (params != null) {
082            clone.queryParameters = params.clone();
083        }
084        return clone;
085    }
086
087}