sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1795339 - in /sis/trunk: ./ core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
Date Tue, 16 May 2017 16:37:59 GMT
Author: desruisseaux
Date: Tue May 16 16:37:58 2017
New Revision: 1795339

URL: http://svn.apache.org/viewvc?rev=1795339&view=rev
Log:
Merge from JDK7 branch.

Modified:
    sis/trunk/   (props changed)
    sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java

Propchange: sis/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 16 16:37:58 2017
@@ -1,5 +1,5 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394364-1758914
-/sis/branches/JDK7:1394913-1795072
-/sis/branches/JDK8:1584960-1795070
+/sis/branches/JDK7:1394913-1795335
+/sis/branches/JDK8:1584960-1795334
 /sis/branches/JDK9:1773327-1789983

Modified: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java?rev=1795339&r1=1795338&r2=1795339&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java [UTF-8]
(original)
+++ sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java [UTF-8]
Tue May 16 16:37:58 2017
@@ -240,6 +240,8 @@ public abstract class AbstractFeature im
 
     /**
      * Executes the parameterless operation of the given name and returns its result.
+     *
+     * @see #getOperationValue(String)
      */
     final Object getOperationResult(final String name) {
         /*
@@ -252,41 +254,6 @@ public abstract class AbstractFeature im
     }
 
     /**
-     * Executes the parameterless operation of the given name and returns the value of its
result.
-     */
-    final Object getOperationValue(final String name) {
-        final AbstractOperation operation = (AbstractOperation) type.getProperty(name);
-        if (operation instanceof LinkOperation) {
-            return getPropertyValue(((LinkOperation) operation).referentName);
-        }
-        final Object result = operation.apply(this, null);
-        if (result instanceof AbstractAttribute<?>) {
-            return getAttributeValue((AbstractAttribute<?>) result);
-        } else if (result instanceof AbstractAssociation) {
-            return getAssociationValue((AbstractAssociation) result);
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * Executes the parameterless operation of the given name and sets the value of its result.
-     */
-    final void setOperationValue(final String name, final Object value) {
-        final AbstractOperation operation = (AbstractOperation) type.getProperty(name);
-        if (operation instanceof LinkOperation) {
-            setPropertyValue(((LinkOperation) operation).referentName, value);
-        } else {
-            final Object result = operation.apply(this, null);
-            if (result instanceof Property) {
-                setPropertyValue((Property) result, value);
-            } else {
-                throw new IllegalStateException(Resources.format(Resources.Keys.CanNotSetPropertyValue_1,
name));
-            }
-        }
-    }
-
-    /**
      * Returns the default value to be returned by {@link #getPropertyValue(String)}
      * for the property of the given name.
      *
@@ -377,6 +344,73 @@ public abstract class AbstractFeature im
     public abstract void setPropertyValue(final String name, final Object value) throws IllegalArgumentException;
 
     /**
+     * Executes the parameterless operation of the given name and returns the value of its
result.
+     * This is a convenience method for sub-classes where some properties may be operations
that
+     * {@linkplain AbstractOperation#getDependencies() depend} on other properties of this
{@code Feature} instance
+     * (for example a {@linkplain FeatureOperations#link link} to another property value).
+     * Invoking this method is equivalent to performing the following steps:
+     *
+     * {@preformat java
+     *     Operation operation = (Operation) type.getProperty(name);
+     *     Property result = operation.apply(this, null);
+     *     if (result instanceof Attribute<?>) {
+     *         return ...;                                      // the attribute value.
+     *     } else if (result instanceof FeatureAssociation) {
+     *         return ...;                                      // the associated feature.
+     *     } else {
+     *         return null;
+     *     }
+     * }
+     *
+     * @param  name  the name of the operation to execute. The caller is responsible to ensure
that the
+     *               property type for that name is an instance of {@link Operation}.
+     * @return the result value of the given operation, or {@code null} if none.
+     *
+     * @since 0.8
+     */
+    protected Object getOperationValue(final String name) {
+        final AbstractOperation operation = (AbstractOperation) type.getProperty(name);
+        if (operation instanceof LinkOperation) {
+            return getPropertyValue(((LinkOperation) operation).referentName);
+        }
+        final Object result = operation.apply(this, null);
+        if (result instanceof AbstractAttribute<?>) {
+            return getAttributeValue((AbstractAttribute<?>) result);
+        } else if (result instanceof AbstractAssociation) {
+            return getAssociationValue((AbstractAssociation) result);
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Executes the parameterless operation of the given name and sets the value of its result.
+     * This method is the complement of {@link #getOperationValue(String)} for subclasses
where
+     * some properties may be operations. Not all operations accept assignments,
+     * but the {@linkplain FeatureOperations#link link} operation for instance does.
+     *
+     * @param  name   the name of the operation to execute. The caller is responsible to
ensure that the
+     *                property type for that name is an instance of {@link Operation}.
+     * @param  value  the value to assign to the result of the named operation.
+     * @throws IllegalStateException if the operation of the given name does not accept assignment.
+     *
+     * @since 0.8
+     */
+    protected void setOperationValue(final String name, final Object value) {
+        final AbstractOperation operation = (AbstractOperation) type.getProperty(name);
+        if (operation instanceof LinkOperation) {
+            setPropertyValue(((LinkOperation) operation).referentName, value);
+        } else {
+            final Object result = operation.apply(this, null);
+            if (result instanceof Property) {
+                setPropertyValue((Property) result, value);
+            } else {
+                throw new IllegalStateException(Resources.format(Resources.Keys.CanNotSetPropertyValue_1,
name));
+            }
+        }
+    }
+
+    /**
      * Returns the value of the given attribute, as a singleton or as a collection depending
      * on the maximum number of occurrences.
      */



Mime
View raw message