/** * Gets the best {@link NullaryHybridCF} implementation for the given types and arguments, * populating its inputs. * * @param ops The {@link OpEnvironment} to search for a matching op. * @param opType The {@link Class} of the operation. If multiple {@link NullaryHybridCF}s share * this type (e.g., the type is an interface which multiple {@link NullaryHybridCF}s * implement), then the best {@link NullaryHybridCF} implementation to use will be selected * automatically from the type and arguments. * @param out The typed output. * @param otherArgs The operation's arguments, excluding the typed output value. * @return A {@link NullaryHybridCF} with populated inputs, ready to use. */ @SuppressWarnings("unchecked") public static <O, OP extends Op> NullaryHybridCF<O> nullaryCF( final OpEnvironment ops, final Class<OP> opType, final O out, final Object... otherArgs) { final Object[] args = OpUtils.args(otherArgs, out); final OpRef<OP> ref = OpRef.createTypes(opType, NullaryHybridCF.class, null, args); return (NullaryHybridCF<O>) ops.op(ref); }
/** * Helper method to populate the {@link Op} nodes. Ops without a valid name will be skipped. Ops * with no namespace will be put in a {@link #NO_NAMESPACE} category. */ private void createNodes(final DefaultMutableTreeNode top) { // Map namespaces and ops to their parent tree node final Map<String, DefaultMutableTreeNode> namespaces = new HashMap<>(); final Map<String, DefaultMutableTreeNode> ops = new HashMap<>(); // Iterate over all ops for (final OpInfo info : opService.infos()) { final String namespace = getName(info.getNamespace(), NO_NAMESPACE); // Get the namespace node for this Op final DefaultMutableTreeNode nsCategory = getCategory(top, namespaces, namespace); final String opName = getName(info.getSimpleName(), info.getName()); if (!opName.isEmpty()) { // get the general Op node for this Op final DefaultMutableTreeNode opCategory = getCategory(nsCategory, ops, opName); // Create a leaf node for this particular Op's signature final DefaultMutableTreeNode opSignature = new DefaultMutableTreeNode(OpUtils.opString(info.cInfo())); opCategory.add(opSignature); } } }
/** * Gets the best {@link BinaryHybridCF} implementation for the given types and arguments, * populating its inputs. * * @param ops The {@link OpEnvironment} to search for a matching op. * @param opType The {@link Class} of the operation. If multiple {@link BinaryHybridCF}s share * this type (e.g., the type is an interface which multiple {@link BinaryHybridCF}s * implement), then the best {@link BinaryHybridCF} implementation to use will be selected * automatically from the type and arguments. * @param out The typed output. * @param in1 The first typed input. * @param in2 The second typed input. * @param otherArgs The operation's arguments, excluding the typed inputs and output values. * @return A {@link BinaryHybridCF} with populated inputs, ready to use. */ @SuppressWarnings("unchecked") public static <I1, I2, O, OP extends Op> BinaryHybridCF<I1, I2, O> binaryCF( final OpEnvironment ops, final Class<OP> opType, final O out, final I1 in1, final I2 in2, final Object... otherArgs) { final Object[] args = OpUtils.args(otherArgs, out, in1, in2); final OpRef<OP> ref = OpRef.createTypes(opType, BinaryHybridCF.class, null, args); return (BinaryHybridCF<I1, I2, O>) ops.op(ref); }