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 *     Robert Browning - initial implementation
018 *     Nuxeo - code review and integration
019 */
020package org.nuxeo.ecm.directory.ldap;
021
022import org.nuxeo.common.xmap.annotation.XNode;
023import org.nuxeo.common.xmap.annotation.XObject;
024import org.nuxeo.ecm.directory.ldap.dns.DNSServiceResolver;
025
026@XObject
027public class LDAPUrlDescriptor {
028
029    @XNode(value = "@srvPrefix")
030    private String srvPrefix = DNSServiceResolver.LDAP_SERVICE_PREFIX;
031
032    @XNode
033    private String value;
034
035    @Override
036    public boolean equals(Object obj) {
037        if (obj instanceof LDAPUrlDescriptor) {
038            return value.equals(((LDAPUrlDescriptor) obj).value)
039                    && srvPrefix.equals(((LDAPUrlDescriptor) obj).srvPrefix);
040        }
041        return false;
042    }
043
044    @Override
045    public int hashCode() {
046        return (srvPrefix + value).hashCode();
047    }
048
049    public String getSrvPrefix() {
050        return srvPrefix;
051    }
052
053    public String getValue() {
054        return value;
055    }
056
057    public void setSrvPrefix(String srvPrefix) {
058        this.srvPrefix = srvPrefix;
059    }
060
061    public void setValue(String value) {
062        this.value = value;
063    }
064}