You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2020/03/02 03:16:10 UTC
[james-project] 13/29: JAMES−3074 Create UidValidity type
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit e9556525d79dbf8a6611080acd3dd1a8881ba70f
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Thu Feb 20 15:58:07 2020 +0700
JAMES−3074 Create UidValidity type
---
.../apache/james/mailbox/model/UidValidity.java | 61 ++++++++++++++++++++++
.../james/mailbox/model/UidValidityTest.java | 41 +++++++++++++++
2 files changed, 102 insertions(+)
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/UidValidity.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/UidValidity.java
new file mode 100644
index 0000000..646b43c
--- /dev/null
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/UidValidity.java
@@ -0,0 +1,61 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailbox.model;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+
+public class UidValidity {
+ public static UidValidity of(long uidValidity) {
+ return new UidValidity(uidValidity);
+ }
+
+ private final long uidValidity;
+
+ private UidValidity(long uidValidity) {
+ this.uidValidity = uidValidity;
+ }
+
+ public long asLong() {
+ return uidValidity;
+ }
+
+ @Override
+ public final boolean equals(Object obj) {
+ if (obj instanceof UidValidity) {
+ UidValidity other = (UidValidity) obj;
+ return Objects.equal(uidValidity, other.uidValidity);
+ }
+ return false;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hashCode(uidValidity);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects
+ .toStringHelper(this)
+ .add("uidValidity", uidValidity)
+ .toString();
+ }
+}
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/UidValidityTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/UidValidityTest.java
new file mode 100644
index 0000000..a77e074
--- /dev/null
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/UidValidityTest.java
@@ -0,0 +1,41 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailbox.model;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.jupiter.api.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+class UidValidityTest {
+ @Test
+ void shouldRespectBeanContract() {
+ EqualsVerifier.forClass(UidValidity.class)
+ .verify();
+ }
+
+ @Test
+ void ofShouldReturnValidUidValidity() {
+ long expectedValue = 123456789L;
+ UidValidity uidValidity = UidValidity.of(expectedValue);
+ assertThat(uidValidity.asLong()).isEqualTo(expectedValue);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org