bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject [12/50] bval git commit: hardening of Groups type
Date Tue, 16 Oct 2018 17:31:16 GMT
hardening of Groups type


Project: http://git-wip-us.apache.org/repos/asf/bval/repo
Commit: http://git-wip-us.apache.org/repos/asf/bval/commit/cc95a745
Tree: http://git-wip-us.apache.org/repos/asf/bval/tree/cc95a745
Diff: http://git-wip-us.apache.org/repos/asf/bval/diff/cc95a745

Branch: refs/heads/bv2
Commit: cc95a745952e0a20582fef449528bd70ceeb3fa4
Parents: 72c936d
Author: Matt Benson <mbenson@apache.org>
Authored: Sat Mar 31 10:57:47 2018 -0500
Committer: Matt Benson <mbenson@apache.org>
Committed: Tue Oct 16 12:28:20 2018 -0500

----------------------------------------------------------------------
 .../main/java/org/apache/bval/jsr/groups/Groups.java   | 13 +++++++------
 .../org/apache/bval/jsr/groups/GroupsComputerTest.java |  6 +++---
 2 files changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bval/blob/cc95a745/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Groups.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Groups.java b/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Groups.java
index 3e7f008..990cdaa 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Groups.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/groups/Groups.java
@@ -19,6 +19,7 @@
 package org.apache.bval.jsr.groups;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import javax.validation.GroupDefinitionException;
@@ -32,19 +33,19 @@ import org.apache.bval.util.Exceptions;
  * @author Roman Stumm
  */
 public class Groups {
+    /** The list of single groups. */
+    private final List<Group> groups = new ArrayList<>();
+
     /** The list of sequences. */
     private final List<List<Group>> sequences = new ArrayList<>();
 
-    /** The list of single groups. */
-    final List<Group> groups = new ArrayList<>();
-
     /**
      * Get the Groups.
      * 
      * @return {@link List} of {@link Group}.
      */
     public List<Group> getGroups() {
-        return groups;
+        return Collections.unmodifiableList(groups);
     }
 
     /**
@@ -53,7 +54,7 @@ public class Groups {
      * @return {@link List} of {@link List} of {@link Group}
      */
     public List<List<Group>> getSequences() {
-        return sequences;
+        return Collections.unmodifiableList(sequences);
     }
 
     /**
@@ -76,7 +77,7 @@ public class Groups {
      */
     void insertSequence(List<Group> groups) {
         if (!(groups == null || groups.isEmpty() || sequences.contains(groups))) {
-            sequences.add(groups);
+            sequences.add(Collections.unmodifiableList(groups));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/bval/blob/cc95a745/bval-jsr/src/test/java/org/apache/bval/jsr/groups/GroupsComputerTest.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/test/java/org/apache/bval/jsr/groups/GroupsComputerTest.java b/bval-jsr/src/test/java/org/apache/bval/jsr/groups/GroupsComputerTest.java
index 4222339..092d527 100644
--- a/bval-jsr/src/test/java/org/apache/bval/jsr/groups/GroupsComputerTest.java
+++ b/bval-jsr/src/test/java/org/apache/bval/jsr/groups/GroupsComputerTest.java
@@ -85,20 +85,20 @@ public class GroupsComputerTest {
         groups.add(Second.class);
         groups.add(Last.class);
         Groups chain = groupsComputer.computeGroups(groups);
-        assertEquals(3, chain.groups.size());
+        assertEquals(3, chain.getGroups().size());
 
         groups.clear();
         groups.add(First.class);
         groups.add(First.class);
         chain = groupsComputer.computeGroups(groups);
-        assertEquals(1, chain.groups.size());
+        assertEquals(1, chain.getGroups().size());
 
         groups.clear();
         groups.add(First.class);
         groups.add(Last.class);
         groups.add(First.class);
         chain = groupsComputer.computeGroups(groups);
-        assertEquals(2, chain.groups.size());
+        assertEquals(2, chain.getGroups().size());
     }
 
     @Test


Mime
View raw message