Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void collectsDbStructure()
        public virtual void CollectsDbStructure()
        {
            // GIVEN
            DbStructureCollector collector = new DbStructureCollector();

            collector.VisitLabel(1, "Person");
            collector.VisitLabel(2, "City");
            collector.VisitPropertyKey(1, "name");
            collector.VisitPropertyKey(2, "income");
            collector.VisitRelationshipType(1, "LIVES_IN");
            collector.VisitRelationshipType(2, "FRIEND");
            collector.VisitIndex(TestIndexDescriptorFactory.uniqueForLabel(1, 1), ":Person(name)", 1.0d, 1L);
            collector.VisitUniqueConstraint(ConstraintDescriptorFactory.uniqueForLabel(2, 1), ":City(name)");
            collector.VisitNodeKeyConstraint(ConstraintDescriptorFactory.nodeKeyForLabel(2, 1), ":City(name)");
            collector.VisitIndex(TestIndexDescriptorFactory.forLabel(2, 2), ":City(income)", 0.2d, 1L);
            collector.VisitAllNodesCount(50);
            collector.VisitNodeCount(1, "Person", 20);
            collector.VisitNodeCount(2, "City", 30);
            collector.VisitRelCount(1, 2, -1, "(:Person)-[:FRIEND]->()", 500);

            // WHEN
            DbStructureLookup lookup = collector.Lookup();

            // THEN
            assertEquals(asList(of(1, "Person"), of(2, "City")), Iterators.asList(lookup.Labels()));
            assertEquals(asList(of(1, "name"), of(2, "income")), Iterators.asList(lookup.Properties()));
            assertEquals(asList(of(1, "LIVES_IN"), of(2, "FRIEND")), Iterators.asList(lookup.RelationshipTypes()));

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertArrayEquals(new string[] { "Person" }, lookup.KnownUniqueIndices().next().first());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertArrayEquals(new string[] { "name" }, lookup.KnownUniqueIndices().next().other());

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertEquals(asList("City"), Iterators.asList(Iterators.map(Pair::first, lookup.KnownNodeKeyConstraints())));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertArrayEquals(new string[] { "name" }, lookup.KnownNodeKeyConstraints().next().other());

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertEquals(asList("City"), Iterators.asList(Iterators.map(Pair::first, lookup.KnownUniqueConstraints())));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertArrayEquals(new string[] { "name" }, lookup.KnownUniqueConstraints().next().other());

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertEquals(new string[] { "City" }, lookup.KnownIndices().next().first());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertArrayEquals(new string[] { "income" }, lookup.KnownIndices().next().other());

            assertEquals(50, lookup.NodesAllCardinality());
            assertEquals(20, lookup.NodesWithLabelCardinality(1));
            assertEquals(30, lookup.NodesWithLabelCardinality(2));
            assertEquals(500, lookup.CardinalityByLabelsAndRelationshipType(1, 2, -1));
            assertEquals(1.0d, lookup.IndexUniqueValueSelectivity(1, 1), 0.01d);
            assertEquals(0.2d, lookup.IndexUniqueValueSelectivity(2, 2), 0.01d);
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void iteratorsStreamForNull()
        internal virtual void IteratorsStreamForNull()
        {
            assertThrows(typeof(System.NullReferenceException), () => Iterators.Stream(null));
        }
Example #3
0
 public static string Join <T1>(string joinString, IEnumerable <T1> iter)
 {
     return(Iterators.Join(joinString, iter.GetEnumerator()));
 }
Example #4
0
 /// <summary>
 /// Create a stream from the given iterable with given characteristics.
 /// <para>
 /// <b>Note:</b> returned stream needs to be closed via <seealso cref="Stream.close()"/> if the given iterable implements
 /// <seealso cref="Resource"/>.
 ///
 /// </para>
 /// </summary>
 /// <param name="iterable"> the iterable to convert to stream </param>
 /// <param name="characteristics"> the logical OR of characteristics for the underlying <seealso cref="Spliterator"/> </param>
 /// @param <T> the type of elements in the given iterable </param>
 /// <returns> stream over the iterable elements </returns>
 /// <exception cref="NullPointerException"> when the given iterable is {@code null} </exception>
 public static Stream <T> Stream <T>(IEnumerable <T> iterable, int characteristics)
 {
     Objects.requireNonNull(iterable);
     return(Iterators.Stream(iterable.GetEnumerator(), characteristics));
 }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SafeVarargs public static <T> Iterable<T> asIterable(final T... array)
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        public static IEnumerable <T> AsIterable <T>(params T[] array)
        {
            return(() => Iterators.Iterator(array));
        }
Example #6
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public static <T> org.neo4j.graphdb.ResourceIterable<T> resourceIterable(final Iterable<T> iterable)
        public static ResourceIterable <T> ResourceIterable <T>(IEnumerable <T> iterable)
        {
            return(() => Iterators.ResourceIterator(iterable.GetEnumerator(), Org.Neo4j.Graphdb.Resource_Fields.Empty));
        }
Example #7
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public static Iterable<long> asIterable(final long... array)
        public static IEnumerable <long> AsIterable(params long[] array)
        {
            return(() => Iterators.asIterator(array));
        }
Example #8
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public static Iterable<int> asIterable(final int... array)
        public static IEnumerable <int> AsIterable(params int[] array)
        {
            return(() => Iterators.asIterator(array));
        }
Example #9
0
 /// <summary>
 /// Adds all the items in {@code iterator} to {@code collection}. </summary>
 /// @param <C> the type of <seealso cref="System.Collections.ICollection"/> to add to items to. </param>
 /// @param <T> the type of items in the collection and iterator. </param>
 /// <param name="iterable"> the <seealso cref="System.Collections.IEnumerator"/> to grab the items from. </param>
 /// <param name="collection"> the <seealso cref="System.Collections.ICollection"/> to add the items to. </param>
 /// <returns> the {@code collection} which was passed in, now filled
 /// with the items from {@code iterator}. </returns>
 public static C AddToCollection <C, T>(IEnumerable <T> iterable, C collection) where C : ICollection <T>
 {
     return(Iterators.AddToCollection(iterable.GetEnumerator(), collection));
 }
Example #10
0
 /// <summary>
 /// Creates a <seealso cref="System.Collections.Generic.ISet<object>"/> from an <seealso cref="System.Collections.IEnumerable"/>.
 /// </summary>
 /// <param name="iterable"> The items to create the set from. </param>
 /// @param <T> The generic type of items. </param>
 /// <returns> a set containing all items from the <seealso cref="System.Collections.IEnumerable"/>. </returns>
 public static ISet <T> AsUniqueSet <T>(IEnumerable <T> iterable)
 {
     return(Iterators.AddToCollectionUnique(iterable, new HashSet <>()));
 }
Example #11
0
 /// <summary>
 /// Returns the iterator's n:th item from the end of the iteration.
 /// If the iterator has got less than n-1 items in it
 /// <seealso cref="NoSuchElementException"/> is thrown.
 /// </summary>
 /// @param <T> the type of elements in {@code iterator}. </param>
 /// <param name="iterable"> the <seealso cref="System.Collections.IEnumerable"/> to get elements from. </param>
 /// <param name="n"> the n:th item from the end to get. </param>
 /// <returns> the iterator's n:th item from the end of the iteration. </returns>
 /// <exception cref="NoSuchElementException"> if the iterator contains less than n-1 items. </exception>
 public static T FromEnd <T>(IEnumerable <T> iterable, int n)
 {
     return(Iterators.FromEnd(iterable.GetEnumerator(), n));
 }
Example #12
0
 /// <summary>
 /// Returns the given iterable's single element or {@code itemIfNone} if no
 /// element found. If there is more than one element in the iterable a
 /// <seealso cref="NoSuchElementException"/> will be thrown.
 ///
 /// If the <seealso cref="Iterable.iterator() iterator"/> created by the {@code iterable} implements <seealso cref="Resource"/>
 /// it will be <seealso cref="Resource.close() closed"/> in a {@code finally} block after the single item
 /// has been retrieved, or failed to be retrieved.
 /// </summary>
 /// @param <T> the type of elements in {@code iterable}. </param>
 /// <param name="iterable"> the <seealso cref="System.Collections.IEnumerable"/> to get elements from. </param>
 /// <param name="itemIfNone"> item to use if none is found </param>
 /// <returns> the single element in {@code iterable}, or {@code null} if no
 /// element found. </returns>
 /// <exception cref="NoSuchElementException"> if more than one element was found. </exception>
 public static T Single <T>(IEnumerable <T> iterable, T itemIfNone)
 {
     return(Iterators.Single(iterable.GetEnumerator(), itemIfNone));
 }
Example #13
0
 /// <summary>
 /// Returns the given iterable's single element. If there are no elements
 /// or more than one element in the iterable a <seealso cref="NoSuchElementException"/>
 /// will be thrown.
 ///
 /// If the <seealso cref="Iterable.iterator() iterator"/> created by the {@code iterable} implements <seealso cref="Resource"/>
 /// it will be <seealso cref="Resource.close() closed"/> in a {@code finally} block after the single item
 /// has been retrieved, or failed to be retrieved.
 /// </summary>
 /// @param <T> the type of elements in {@code iterable}. </param>
 /// <param name="iterable"> the <seealso cref="System.Collections.IEnumerable"/> to get elements from. </param>
 /// <returns> the single element in the {@code iterable}. </returns>
 /// <exception cref="NoSuchElementException"> if there isn't exactly one element. </exception>
 public static T Single <T>(IEnumerable <T> iterable)
 {
     return(Iterators.Single(iterable.GetEnumerator()));
 }
Example #14
0
 /// <summary>
 /// Returns the given iterable's last element. If no element is found a
 /// <seealso cref="NoSuchElementException"/> is thrown.
 /// </summary>
 /// @param <T> the type of elements in {@code iterable}. </param>
 /// <param name="iterable"> the <seealso cref="System.Collections.IEnumerable"/> to get elements from. </param>
 /// <returns> the last element in the {@code iterable}. </returns>
 /// <exception cref="NoSuchElementException"> if no element found. </exception>
 public static T Last <T>(IEnumerable <T> iterable)
 {
     return(Iterators.Last(iterable.GetEnumerator()));
 }
Example #15
0
 public override ResourceIterator <T> Iterator()
 {
     return(Iterators.EmptyResourceIterator());
 }