001/*
002 * (C) Copyright 2014 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 *     Thierry Martins
018 */
019
020package org.nuxeo.ecm.platform.web.common.requestcontroller.service;
021
022import org.nuxeo.common.xmap.annotation.XContent;
023import org.nuxeo.common.xmap.annotation.XNode;
024import org.nuxeo.common.xmap.annotation.XObject;
025
026/**
027 * @author <a href="mailto:tm@nuxeo.com">Thierry Martins</a>
028 * @since 6.0
029 */
030@XObject(value = "header")
031public class NuxeoHeaderDescriptor implements Cloneable {
032
033    @XNode("@name")
034    protected String name;
035
036    @XNode("@enabled")
037    protected Boolean enabled = true;
038
039    protected String value;
040
041    public String getValue() {
042        return value;
043    }
044
045    @XContent
046    public void setValue(String value) {
047        if (value != null) {
048            this.value = value.trim();
049        }
050    }
051
052    public String getName() {
053        return name;
054    }
055
056    public boolean isEnabled() {
057        return enabled;
058    }
059
060    @Override
061    public NuxeoHeaderDescriptor clone() throws CloneNotSupportedException {
062        NuxeoHeaderDescriptor d = new NuxeoHeaderDescriptor();
063        d.name = name;
064        d.enabled = enabled;
065        d.value = value;
066        return d;
067    }
068
069    public void merge(NuxeoHeaderDescriptor source) {
070        enabled = source.enabled;
071        if (source.value != null) {
072            value = source.value;
073        }
074    }
075
076}