CCM NG: Some classes for representing WebDAV properties

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5376 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2018-04-17 16:43:00 +00:00
parent 847ac5edfe
commit bd4c210bf7
8 changed files with 1036 additions and 0 deletions

View File

@ -0,0 +1,114 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.xml.elements.properties;
import org.libreccm.webdav.ConstantsAdapter;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
* WebDAV getcontentlanguage Property.
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#PROPERTY_getcontentlanguage">Chapter
* 15.3 "getcontentlanguage Property" of RFC 4918 "HTTP Extensions for Web
* Distributed Authoring and Versioning (WebDAV)"</a>
*
*/
@XmlJavaTypeAdapter(GetContentLanguage.Adapter.class)
@XmlRootElement(name = "getcontentlanguage")
public final class GetContentLanguage {
public static final GetContentLanguage GETCONTENTLANGUAGE
= new GetContentLanguage();
@XmlValue
private final String languageTag;
private GetContentLanguage() {
this.languageTag = "";
}
public GetContentLanguage(final String languageTag) {
this.languageTag = Objects.requireNonNull(languageTag);
}
public final String getLanguageTag() {
return this.languageTag;
}
@Override
public int hashCode() {
int hash = 5;
hash = 67 * hash + Objects.hashCode(languageTag);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GetContentLanguage)) {
return false;
}
final GetContentLanguage other = (GetContentLanguage) obj;
return Objects.equals(languageTag, other.getLanguageTag());
}
@Override
public String toString() {
return String.format("%s{ languageTag = \"%s\" }",
languageTag);
}
/**
* Guarantees that any unmarshalled enum constants effectively are the
* constant Java instances itself, so that {@code ==} can be used form
* comparison.
*
*/
protected static final class Adapter
extends ConstantsAdapter<GetContentLanguage> {
@Override
protected final Collection<GetContentLanguage> getConstants() {
return Collections.singleton(GETCONTENTLANGUAGE);
}
}
}

View File

@ -0,0 +1,153 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.xml.elements.properties;
import org.libreccm.webdav.ConstantsAdapter;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import static javax.xml.bind.annotation.XmlAccessType.*;
/**
*
* WebDAV getcontentlength Property.
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#PROPERTY_getcontentlength">Chapter
* 15.4 "getcontentlength Property" of RFC 4918 "HTTP Extensions for Web
* Distributed Authoring and Versioning (WebDAV)"</a>
*
*
*/
@XmlAccessorType(NONE)
@XmlJavaTypeAdapter(GetContentLength.Adapter.class)
@XmlRootElement(name = "getcontentlength")
public final class GetContentLength {
/**
* Singleton empty instance for use as property name only, providing
* improved performance and the ability to compare by <em>same</em>
* instance.
*
* @since 1.2
*/
public static final GetContentLength GETCONTENTLENGTH
= new GetContentLength();
private Long contentLength;
@SuppressWarnings("unused")
private String getXmlValue() {
if (contentLength == null) {
return null;
} else {
return Long.toString(contentLength);
}
}
@XmlValue
private void setXmlValue(final String xmlValue) {
if (xmlValue == null || xmlValue.isEmpty()) {
contentLength = null;
} else {
contentLength = Long.parseLong(xmlValue);
}
this.contentLength = xmlValue == null || xmlValue.isEmpty() ? null
: Long.parseLong(xmlValue);
}
private GetContentLength() {
// For unmarshalling only
}
public GetContentLength(final long contentLength) {
this.contentLength = contentLength;
}
public final long getContentLength() {
if (contentLength == null) {
return 0;
} else {
return contentLength;
}
}
@Override
public int hashCode() {
int hash = 7;
hash = 47 * hash + Objects.hashCode(contentLength);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GetContentLength)) {
return false;
}
final GetContentLength other = (GetContentLength) obj;
return Objects.equals(contentLength, other.getContentLength());
}
@Override
public String toString() {
return String.format("%s{ contentLength = %d }",
super.toString(),
contentLength);
}
/**
* Guarantees that any unmarshalled enum constants effectively are the
* constant Java instances itself, so that {@code ==} can be used form
* comparison.
*
*/
protected static final class Adapter
extends ConstantsAdapter<GetContentLength> {
@Override
protected final Collection<GetContentLength> getConstants() {
return Collections.singleton(GETCONTENTLENGTH);
}
}
}

View File

@ -0,0 +1,115 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.xml.elements.properties;
import org.libreccm.webdav.ConstantsAdapter;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
* WebDAV getcontenttype Property.
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#PROPERTY_getcontenttype">Chapter
* 15.5 "getcontenttype Property" of RFC 4918 "HTTP Extensions for Web
* Distributed Authoring and Versioning (WebDAV)"</a>
*
*
*/
@XmlJavaTypeAdapter(GetContentType.Adapter.class)
@XmlRootElement(name = "getcontenttype")
public final class GetContentType {
/**
* Singleton empty instance for use as property name only, providing
* improved performance and the ability to compare by <em>same</em>
* instance.
*
*/
public static final GetContentType GETCONTENTTYPE = new GetContentType();
@XmlValue
private final String mediaType;
private GetContentType() {
this.mediaType = "";
}
public GetContentType(final String mediaType) {
this.mediaType = Objects.requireNonNull(mediaType);
}
public final String getMediaType() {
return this.mediaType;
}
@Override
public int hashCode() {
int hash = 7;
hash = 61 * hash + Objects.hashCode(mediaType);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GetContentType)) {
return false;
}
final GetContentType other = (GetContentType) obj;
return Objects.equals(mediaType, other.getMediaType());
}
@Override
public String toString() {
return String.format("%s{ mediaType = \"%s\" }",
super.toString(),
mediaType);
}
protected static final class Adapter
extends ConstantsAdapter<GetContentType> {
@Override
protected final Collection<GetContentType> getConstants() {
return Collections.singleton(GETCONTENTTYPE);
}
}
}

View File

@ -0,0 +1,122 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.xml.elements.properties;
import org.libreccm.webdav.ConstantsAdapter;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
*
* WebDAV getetag Property.
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#PROPERTY_getetag">Chapter
* 15.6 "getetag Property" of RFC 4918 "HTTP Extensions for Web Distributed
* Authoring and Versioning (WebDAV)"</a>
*
*
*/
@XmlJavaTypeAdapter(GetETag.Adapter.class)
@XmlRootElement(name = "getetag")
public final class GetETag {
/**
* Singleton empty instance for use as property name only, providing
* improved performance and the ability to compare by <em>same</em>
* instance.
*
*/
public static final GetETag GETETAG = new GetETag();
@XmlValue
private final String entityTag;
private GetETag() {
this.entityTag = "";
}
public GetETag(final String entityTag) {
this.entityTag = Objects.requireNonNull(entityTag);
}
public final String getEntityTag() {
return entityTag;
}
@Override
public int hashCode() {
int hash = 5;
hash = 37 * hash + Objects.hashCode(entityTag);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GetETag)) {
return false;
}
final GetETag other = (GetETag) obj;
return Objects.equals(entityTag, other.getEntityTag());
}
@Override
public String toString() {
return String.format("%s{ entityTag = \"%s\" }",
super.toString(),
entityTag);
}
/**
* Guarantees that any unmarshalled enum constants effectively are the
* constant Java instances itself, so that {@code ==} can be used form
* comparison.
*
* @since 1.2
*/
protected static final class Adapter extends ConstantsAdapter<GetETag> {
@Override
protected final Collection<GetETag> getConstants() {
return Collections.singleton(GETETAG);
}
}
}

View File

@ -0,0 +1,149 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.xml.elements.properties;
import org.libreccm.webdav.ConstantsAdapter;
import org.libreccm.webdav.xml.elements.Rfc1123DateFormat;
import java.text.ParseException;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Objects;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
*
* WebDAV getlastmodified Property.
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#PROPERTY_getlastmodified">Chapter
* 15.7 "getlastmodified Property" of RFC 4918 "HTTP Extensions for Web
* Distributed Authoring and Versioning (WebDAV)"</a>
*
*/
@XmlJavaTypeAdapter(GetLastModified.Adapter.class)
@XmlRootElement(name = "getlastmodified")
public final class GetLastModified {
/**
* Singleton empty instance for use as property name only, providing
* improved performance and the ability to compare by <em>same</em>
* instance.
*
*/
public static final GetLastModified GETLASTMODIFIED = new GetLastModified();
private Date dateTime;
private GetLastModified() {
// For unmarshalling only.
}
public GetLastModified(final Date dateTime) {
this.dateTime = Objects.requireNonNull(dateTime);
}
public final Date getDateTime() {
if (dateTime == null) {
return null;
} else {
return (Date) dateTime.clone();
}
}
@XmlValue
private String getXmlValue() {
if (dateTime == null) {
return null;
} else {
return new Rfc1123DateFormat().format(dateTime);
}
}
@SuppressWarnings("unused")
private void setXmlValue(final String xmlValue) throws ParseException {
if (xmlValue == null || xmlValue.isEmpty()) {
dateTime = null;
} else {
dateTime = new Rfc1123DateFormat().parse(xmlValue);
}
}
@Override
public int hashCode() {
int hash = 3;
hash = 79 * hash + Objects.hashCode(dateTime);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GetLastModified)) {
return false;
}
final GetLastModified other = (GetLastModified) obj;
return Objects.equals(dateTime, other.getDateTime());
}
@Override
public String toString() {
return String.format("%s{ dateTime = %s }",
super.toString(),
Objects.toString(dateTime));
}
/**
* Guarantees that any unmarshalled enum constants effectively are the
* constant Java instances itself, so that {@code ==} can be used form
* comparison.
*
*/
protected static final class Adapter
extends ConstantsAdapter<GetLastModified> {
@Override
protected final Collection<GetLastModified> getConstants() {
return Collections.singleton(GETLASTMODIFIED);
}
}
}

View File

@ -0,0 +1,126 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.xml.elements.properties;
import org.libreccm.webdav.ConstantsAdapter;
import org.libreccm.webdav.xml.elements.ActiveLock;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
* WebDAV lockdiscovery Property.
*
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#PROPERTY_lockdiscovery">Chapter
* 15.8 "lockdiscovery Property" of RFC 4918 "HTTP Extensions for Web
* Distributed Authoring and Versioning (WebDAV)"</a>
*
*/
@XmlJavaTypeAdapter(LockDiscovery.Adapter.class)
@XmlRootElement(name = "lockdiscovery")
public final class LockDiscovery {
/**
* Singleton empty instance for use as property name only, providing
* improved performance and the ability to compare by <em>same</em>
* instance.
*
*/
public static final LockDiscovery LOCKDISCOVERY = new LockDiscovery();
@XmlElement(name = "activelock")
private final List<ActiveLock> activeLocks;
private LockDiscovery() {
this.activeLocks = new LinkedList<>();
}
public LockDiscovery(final ActiveLock... activeLocks) {
this.activeLocks = Arrays.asList(Objects.requireNonNull(activeLocks));
}
public final List<ActiveLock> getActiveLocks() {
return Collections.unmodifiableList(activeLocks);
}
@Override
public int hashCode() {
int hash = 3;
hash = 61 * hash + Objects.hashCode(activeLocks);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof LockDiscovery)) {
return false;
}
final LockDiscovery other = (LockDiscovery) obj;
return Objects.equals(activeLocks, other.getActiveLocks());
}
@Override
public String toString() {
return String.format("%s{ activeLocks = %s }",
super.toString(),
Objects.toString(activeLocks));
}
/**
* Guarantees that any unmarshalled enum constants effectively are the
* constant Java instances itself, so that {@code ==} can be used form
* comparison.
*
*/
protected static final class Adapter
extends ConstantsAdapter<LockDiscovery> {
@Override
protected final Collection<LockDiscovery> getConstants() {
return Collections.singleton(LOCKDISCOVERY);
}
}
}

View File

@ -0,0 +1,131 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.xml.elements.properties;
import org.libreccm.webdav.ConstantsAdapter;
import org.libreccm.webdav.xml.elements.Collection;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
* WebDAV resourcetype Property.
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#PROPERTY_resourcetype">Chapter
* 15.9 "resourcetype Property" of RFC 4918 "HTTP Extensions for Web Distributed
* Authoring and Versioning (WebDAV)"</a>
*
*
*/
@XmlJavaTypeAdapter(ResourceType.Adapter.class)
@XmlRootElement(name = "resourcetype")
public final class ResourceType {
/**
* Singleton empty instance for use as property name only, providing
* improved performance and the ability to compare by <em>same</em>
* instance.
*
* @since 1.2
*/
public static final ResourceType RESOURCETYPE = new ResourceType();
@XmlAnyElement(lax = true)
private final List<Object> resourceTypes;
public static final ResourceType COLLECTION = new ResourceType(
Collection.COLLECTION);
private ResourceType() {
this.resourceTypes = new LinkedList<>();
}
public ResourceType(final Object... resourceTypes) {
this.resourceTypes = Arrays.asList(
Objects.requireNonNull(resourceTypes));
}
public final List<Object> getResourceTypes() {
return Collections.unmodifiableList(this.resourceTypes);
}
@Override
public int hashCode() {
int hash = 3;
hash = 97 * hash + Objects.hashCode(resourceTypes);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ResourceType)) {
return false;
}
final ResourceType other = (ResourceType) obj;
return Objects.equals(resourceTypes, other.getResourceTypes());
}
@Override
public String toString() {
return String.format("%s{ resourceTypes = %s }",
super.toString(),
Objects.toString(resourceTypes));
}
/**
* Guarantees that any unmarshalled enum constants effectively are the
* constant Java instances itself, so that {@code ==} can be used form
* comparison.
*
*/
protected static final class Adapter
extends ConstantsAdapter<ResourceType> {
@Override
protected final java.util.Collection<ResourceType> getConstants() {
return Arrays.asList(RESOURCETYPE, COLLECTION);
}
}
}

View File

@ -0,0 +1,126 @@
/*
* Copyright (C) 2018 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.webdav.xml.elements.properties;
import org.libreccm.webdav.ConstantsAdapter;
import org.libreccm.webdav.xml.elements.LockEntry;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
*
* WebDAV supportedlock Property.
*
* The class is based on a class/interface from java.net WebDAV Project:
*
* <a href="https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java">https://gitlab.com/headcrashing/webdav-jaxrs/blob/master/src/main/java/net/java/dev/webdav/jaxrs/Headers.java</a>
*
*
* @author Markus KARG (mkarg@java.net)
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*
* @see
* <a href="http://www.webdav.org/specs/rfc4918.html#PROPERTY_supportedlock">Chapter
* 15.10 "supportedlock Property" of RFC 4918 "HTTP Extensions for Web
* Distributed Authoring and Versioning (WebDAV)"</a>
*
*/
@XmlJavaTypeAdapter(SupportedLock.Adapter.class)
@XmlRootElement(name = "supportedlock")
public final class SupportedLock {
/**
* Singleton empty instance for use as property name only, providing
* improved performance and the ability to compare by <em>same</em>
* instance.
*
*/
public static final SupportedLock SUPPORTEDLOCK = new SupportedLock();
@XmlElement(name = "lockentry")
private final List<LockEntry> lockEntries;
private SupportedLock() {
this.lockEntries = new LinkedList<>();
}
public SupportedLock(final LockEntry... lockEntries) {
this.lockEntries = Arrays.asList(Objects.requireNonNull(lockEntries));
}
public final List<LockEntry> getLockEntries() {
return Collections.unmodifiableList(lockEntries);
}
@Override
public int hashCode() {
int hash = 7;
hash = 29 * hash + Objects.hashCode(lockEntries);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof SupportedLock)) {
return false;
}
final SupportedLock other = (SupportedLock) obj;
return Objects.equals(lockEntries, other.getLockEntries());
}
@Override
public String toString() {
return String.format("%s{ lockEntries = %s }",
super.toString(),
Objects.toString(lockEntries));
}
/**
* Guarantees that any unmarshalled enum constants effectively are the
* constant Java instances itself, so that {@code ==} can be used form
* comparison.
*
*/
protected static final class Adapter
extends ConstantsAdapter<SupportedLock> {
@Override
protected final Collection<SupportedLock> getConstants() {
return Collections.singleton(SUPPORTEDLOCK);
}
}
}