コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUseResultOfFirstNonEmpty()
        public virtual void ShouldUseResultOfFirstNonEmpty()
        {
            // given
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            Filter <int> removeValuesOfFive = data => data.Where(value => value != 5).collect(Collectors.toSet());
            Filter <int> countMoreThanFour  = data => data.size() > 4 ? data : Collections.emptySet();
            Filter <int> countMoreThanThree = data => data.size() > 3 ? data : Collections.emptySet();

            FilterChain <int> ruleA = new FilterChain <int>(new IList <Filter <T> > {
                removeValuesOfFive, countMoreThanFour
            });                                                                                                                            // should not succeed
            FilterChain <int> ruleB = new FilterChain <int>(new IList <Filter <T> > {
                removeValuesOfFive, countMoreThanThree
            });                                                                                                // should succeed
            FilterChain <int> ruleC = new FilterChain <int>(singletonList(countMoreThanFour));                 // never reached

            FirstValidRule <int> firstValidRule = new FirstValidRule <int>(new IList <FilterChain <T> > {
                ruleA, ruleB, ruleC
            });

            ISet <int> data = asSet(5, 1, 5, 2, 5, 3, 5, 4);

            // when
            data = firstValidRule.Apply(data);

            // then
            assertEquals(asSet(1, 2, 3, 4), data);
        }
コード例 #2
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || this.GetType() != o.GetType())
            {
                return(false);
            }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: FirstValidRule<?> that = (FirstValidRule<?>) o;
            FirstValidRule <object> that = (FirstValidRule <object>)o;

            return(Objects.Equals(_rules, that._rules));
        }