sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1778905 - in /sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis: internal/util/Acyclic.java util/collection/DefaultTreeTable.java util/collection/TreeTableFormat.java
Date Sun, 15 Jan 2017 10:54:45 GMT
Author: desruisseaux
Date: Sun Jan 15 10:54:44 2017
New Revision: 1778905

URL: http://svn.apache.org/viewvc?rev=1778905&view=rev
Log:
Replace the check for DefaultTreeTable.Node special case by a mechanism less hidden.

Added:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Acyclic.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java

Added: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Acyclic.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Acyclic.java?rev=1778905&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Acyclic.java
(added)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Acyclic.java
[UTF-8] Sun Jan 15 10:54:44 2017
@@ -0,0 +1,42 @@
+/*
+ * 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.sis.internal.util;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Marker annotation for implementation that promise to not introduce a cyclic graph
+ * in a structure that could potentially contains such cycles. If this annotation is
+ * present, then some Apache SIS classes may skip the safety checks against infinite
+ * recursivity.
+ *
+ * <p>This annotation is not inherited, since a promise that a particular class will
not
+ * introduce cyclic graphs does not mean that subclasses will hold the same promise.</p>
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.8
+ * @version 0.8
+ * @module
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Acyclic {
+}

Propchange: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Acyclic.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Acyclic.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java?rev=1778905&r1=1778904&r2=1778905&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
[UTF-8] Sun Jan 15 10:54:44 2017
@@ -27,6 +27,7 @@ import java.io.Serializable;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.util.Cloner;
+import org.apache.sis.internal.util.Acyclic;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 
 import static org.apache.sis.util.CharSequences.trimWhitespaces;
@@ -321,6 +322,7 @@ public class DefaultTreeTable implements
      * @see DefaultTreeTable
      * @see TableColumn
      */
+    @Acyclic
     public static class Node implements TreeTable.Node, Cloneable, Serializable {
         /**
          * For cross-version compatibility.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java?rev=1778905&r1=1778904&r2=1778905&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java
[UTF-8] Sun Jan 15 10:54:44 2017
@@ -47,6 +47,7 @@ import org.apache.sis.util.CharSequences
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.resources.Vocabulary;
+import org.apache.sis.internal.util.Acyclic;
 import org.apache.sis.internal.util.LocalizedParseException;
 
 import static org.apache.sis.util.Characters.NO_BREAK_SPACE;
@@ -769,7 +770,7 @@ public class TreeTableFormat extends Tab
              * a real check of values and children, which is a little bit costly and known
to be unnecessary in that
              * particular case.
              */
-            final boolean omitCheck = (node.getClass() == DefaultTreeTable.Node.class);
+            final boolean omitCheck = node.getClass().isAnnotationPresent(Acyclic.class);
             if (omitCheck || recursivityGuard.add(node)) {
                 final Iterator<? extends TreeTable.Node> it = node.getChildren().iterator();
                 boolean hasNext = it.hasNext();



Mime
View raw message