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 *      Vladimir Pasquier <vpasquier@nuxeo.com>
018 */
019package org.nuxeo.binary.metadata.internals;
020
021import java.util.ArrayList;
022import java.util.List;
023
024import org.nuxeo.common.xmap.annotation.XNode;
025import org.nuxeo.common.xmap.annotation.XNodeList;
026import org.nuxeo.common.xmap.annotation.XObject;
027
028/**
029 * @since 7.1
030 */
031@XObject("rule")
032public class MetadataRuleDescriptor {
033
034    @XNode("@id")
035    protected String id;
036
037    @XNode("@order")
038    protected Integer order;
039
040    @XNode("@enabled")
041    protected Boolean enabled;
042
043    @XNode("@async")
044    protected Boolean isAsync;
045
046    @XNodeList(value = "metadataMappings/metadataMapping-id", componentType = String.class, type = ArrayList.class)
047    protected List<String> metadataMappingIdDescriptors;
048
049    @XNodeList(value = "filters/filter-id", type = ArrayList.class, componentType = String.class)
050    protected List<String> filterIds;
051
052    public String getId() {
053        return id;
054    }
055
056    public Integer getOrder() {
057        return order;
058    }
059
060    public Boolean getEnabled() {
061        return enabled;
062    }
063
064    public Boolean getIsAsync() {
065        return isAsync;
066    }
067
068    public List<String> getMetadataMappingIdDescriptors() {
069        return metadataMappingIdDescriptors;
070    }
071
072    public List<String> getFilterIds() {
073        return filterIds;
074    }
075
076    @Override
077    public String toString() {
078        return "MetadataRuleDescriptor [id=" + id + "]";
079    }
080
081    @Override
082    public int hashCode() {
083        final int prime = 31;
084        int result = 1;
085        result = prime * result + ((id == null) ? 0 : id.hashCode());
086        return result;
087    }
088
089    @Override
090    public boolean equals(Object obj) {
091        if (this == obj) {
092            return true;
093        }
094        if (obj == null) {
095            return false;
096        }
097        if (getClass() != obj.getClass()) {
098            return false;
099        }
100        MetadataRuleDescriptor other = (MetadataRuleDescriptor) obj;
101        if (id == null) {
102            if (other.id != null) {
103                return false;
104            }
105        } else if (!id.equals(other.id)) {
106            return false;
107        }
108        return true;
109    }
110
111}