List of usage examples for java.util Collection toArray
default <T> T[] toArray(IntFunction<T[]> generator)
From source file:org.reusables.dbunit.DbUnitDatasetExecutionListener.java
/** * Load the dataset using the given annotation information. * //from w w w . ja v a 2 s .c om * @param operation The operation to perform. * @param testContext The context for the current test. * @param classAnnotation Dataset resource information of the test class. * @param methodAnnotation Dataset resource information of the test method. * @throws Exception Any error. * @since 1.3.0 */ protected void handleDataset(final DatabaseOperation operation, final TestContext testContext, final DbUnitDataset classAnnotation, final DbUnitDataset methodAnnotation) throws Exception { LOG.debug("Getting datasets for operation: {}", operation.getClass().getSimpleName()); final Collection<IDataSet> datasets = new ArrayList<IDataSet>(); datasets.addAll(createDataSets(testContext, classAnnotation, false)); datasets.addAll(createDataSets(testContext, methodAnnotation, true)); if (datasets.isEmpty()) { LOG.debug("No datasets found."); return; } final IDataSet dataset = createAutoCompletionDataSet( new CompositeDataSet(datasets.toArray(new IDataSet[0])), testContext); final ConnectionType connectionType = getConnectionType(testContext, classAnnotation); handleOperation(new DatasetTask(operation, dataset), testContext, connectionType); }
From source file:net.ontopia.topicmaps.db2tm.Processor.java
protected static List<TopicNameIF> getTopicNames(TopicIF topic, Relation relation, Entity entity, Field field, String[] tuple, Context ctx) { TopicIF type = Utils.getTopic(field.getType(), ctx); if (type == null) { if (field.getType() != null) throw new DB2TMInputException("Name type not found", entity, tuple, field.getType()); // this means the type is the default name type. sync of this will fail // because null != defaultnametype. type = getDefaultNameType(ctx);//from ww w .jav a 2s . c o m } // loop over names and update List<TopicNameIF> result = new ArrayList<TopicNameIF>(); Collection<TopicNameIF> bns = topic.getTopicNames(); if (!bns.isEmpty()) { TopicNameIF[] ba = bns.toArray(new TopicNameIF[0]); for (int i = 0; i < ba.length; i++) { TopicNameIF _bn = ba[i]; // check type TopicIF _type = _bn.getType(); if (!Objects.equals(_type, type)) continue; // check scope if (!compareScope(field.getScope(), _bn.getScope(), entity, tuple, ctx)) continue; result.add(_bn); } } return result; }