+
+ /**
+ * Check if this particular (subclass) transcriber's dependencies are met.
+ * Default implementation just returns true. Some but not all transcribers will customize this.
+ *
+ * <p>Implementations *MUST* use the passed in transaction. They will typically call the
+ * {@link #exists(String, ReadTransaction)} method on ANOTHER transcriber with it.
+ *
+ * <p>Implementations should chain {@link #ifNonNull(Object, Function)}, or perform null safe comparisons otherwise,
+ * for any optional non-mandatory {@link NeutronObject} properties which may well be null.
+ *
+ * @param tx the transaction within which to perform reads to check for dependencies
+ * @param neutronObject the incoming main neutron object in which there may be references to dependencies
+ *
+ * @return true if all dependencies are available and
+ * {@link #add(INeutronObject)} operation can proceed; false if there
+ * are unmet dependencies, which will cause the add to abort, and a respective
+ * error code returned to the caller.
+ */
+ protected boolean areAllDependenciesAvailable(ReadTransaction tx, S neutronObject) {
+ return true;
+ }
+
+ /**
+ * Utility to perform well readable code of null-safe chains of e.g.
+ * {@link #exists(String, ReadTransaction)} method calls.
+ */
+ protected static final <X> boolean ifNonNull(
+ @Nullable X property, Function<@NonNull X, @NonNull Boolean> function) {
+ if (property != null) {
+ Boolean result = function.apply(property);
+ Preconditions.checkNotNull(result, "result");
+ return result;
+ } else {
+ // We return true, in line with the default implementation
+ // in org.opendaylight.neutron.transcriber.AbstractTranscriberInterface.
+ // areAllDependenciesAvailable(ReadTransaction, S)
+ return true;
+ }
+ }
+