├── .gitignore ├── LICENSE ├── LambdajDemoTest.bat ├── README ├── html ├── apidocs │ ├── allclasses-frame.html │ ├── allclasses-noframe.html │ ├── ch │ │ └── lambdaj │ │ │ ├── Lambda.html │ │ │ ├── class-use │ │ │ └── Lambda.html │ │ │ ├── collection │ │ │ ├── LambdaCollection.html │ │ │ ├── LambdaCollections.html │ │ │ ├── LambdaGroup.html │ │ │ ├── LambdaIterable.html │ │ │ ├── LambdaIterator.html │ │ │ ├── LambdaList.html │ │ │ ├── LambdaMap.html │ │ │ ├── LambdaSet.html │ │ │ ├── class-use │ │ │ │ ├── LambdaCollection.html │ │ │ │ ├── LambdaCollections.html │ │ │ │ ├── LambdaGroup.html │ │ │ │ ├── LambdaIterable.html │ │ │ │ ├── LambdaIterator.html │ │ │ │ ├── LambdaList.html │ │ │ │ ├── LambdaMap.html │ │ │ │ └── LambdaSet.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ │ ├── function │ │ │ ├── aggregate │ │ │ │ ├── Aggregator.html │ │ │ │ ├── Avg.html │ │ │ │ ├── Chooser.html │ │ │ │ ├── ChooserOnArgument.html │ │ │ │ ├── Concat.html │ │ │ │ ├── InitializedPairAggregator.html │ │ │ │ ├── Max.html │ │ │ │ ├── MaxOnArgument.html │ │ │ │ ├── Min.html │ │ │ │ ├── MinOnArgument.html │ │ │ │ ├── PairAggregator.html │ │ │ │ ├── ProxyAggregator.html │ │ │ │ ├── Sum.html │ │ │ │ ├── SumDouble.html │ │ │ │ ├── SumInteger.html │ │ │ │ ├── SumLong.html │ │ │ │ ├── class-use │ │ │ │ │ ├── Aggregator.html │ │ │ │ │ ├── Avg.html │ │ │ │ │ ├── Chooser.html │ │ │ │ │ ├── ChooserOnArgument.html │ │ │ │ │ ├── Concat.html │ │ │ │ │ ├── InitializedPairAggregator.html │ │ │ │ │ ├── Max.html │ │ │ │ │ ├── MaxOnArgument.html │ │ │ │ │ ├── Min.html │ │ │ │ │ ├── MinOnArgument.html │ │ │ │ │ ├── PairAggregator.html │ │ │ │ │ ├── ProxyAggregator.html │ │ │ │ │ ├── Sum.html │ │ │ │ │ ├── SumDouble.html │ │ │ │ │ ├── SumInteger.html │ │ │ │ │ └── SumLong.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ └── package-use.html │ │ │ ├── argument │ │ │ │ ├── Argument.html │ │ │ │ ├── ArgumentConversionException.html │ │ │ │ ├── ArgumentsFactory.html │ │ │ │ ├── FinalClassArgumentCreator.html │ │ │ │ ├── Invoker.html │ │ │ │ ├── class-use │ │ │ │ │ ├── Argument.html │ │ │ │ │ ├── ArgumentConversionException.html │ │ │ │ │ ├── ArgumentsFactory.html │ │ │ │ │ ├── FinalClassArgumentCreator.html │ │ │ │ │ └── Invoker.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ └── package-use.html │ │ │ ├── closure │ │ │ │ ├── Closure.html │ │ │ │ ├── Closure0.html │ │ │ │ ├── Closure1.html │ │ │ │ ├── Closure2.html │ │ │ │ ├── Closure3.html │ │ │ │ ├── Closure4.html │ │ │ │ ├── ClosureResult.html │ │ │ │ ├── ClosuresFactory.html │ │ │ │ ├── DelayedClosure.html │ │ │ │ ├── Switcher.html │ │ │ │ ├── WrongClosureInvocationException.html │ │ │ │ ├── class-use │ │ │ │ │ ├── Closure.html │ │ │ │ │ ├── Closure0.html │ │ │ │ │ ├── Closure1.html │ │ │ │ │ ├── Closure2.html │ │ │ │ │ ├── Closure3.html │ │ │ │ │ ├── Closure4.html │ │ │ │ │ ├── ClosureResult.html │ │ │ │ │ ├── ClosuresFactory.html │ │ │ │ │ ├── DelayedClosure.html │ │ │ │ │ ├── Switcher.html │ │ │ │ │ └── WrongClosureInvocationException.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ └── package-use.html │ │ │ ├── compare │ │ │ │ ├── ArgumentComparator.html │ │ │ │ ├── ComparatorUtil.html │ │ │ │ ├── PropertyComparator.html │ │ │ │ ├── class-use │ │ │ │ │ ├── ArgumentComparator.html │ │ │ │ │ ├── ComparatorUtil.html │ │ │ │ │ └── PropertyComparator.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ └── package-use.html │ │ │ ├── convert │ │ │ │ ├── AliasedArgumentConverter.html │ │ │ │ ├── ArgumentConverter.html │ │ │ │ ├── ConstructorArgumentConverter.html │ │ │ │ ├── Converter.html │ │ │ │ ├── ConverterIterator.html │ │ │ │ ├── DefaultStringConverter.html │ │ │ │ ├── ProjectConverter.html │ │ │ │ ├── PropertyExtractor.html │ │ │ │ ├── StringConverter.html │ │ │ │ ├── StringLengthConverter.html │ │ │ │ ├── StringPropertyExtractor.html │ │ │ │ ├── class-use │ │ │ │ │ ├── AliasedArgumentConverter.html │ │ │ │ │ ├── ArgumentConverter.html │ │ │ │ │ ├── ConstructorArgumentConverter.html │ │ │ │ │ ├── Converter.html │ │ │ │ │ ├── ConverterIterator.html │ │ │ │ │ ├── DefaultStringConverter.html │ │ │ │ │ ├── ProjectConverter.html │ │ │ │ │ ├── PropertyExtractor.html │ │ │ │ │ ├── StringConverter.html │ │ │ │ │ ├── StringLengthConverter.html │ │ │ │ │ └── StringPropertyExtractor.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ └── package-use.html │ │ │ └── matcher │ │ │ │ ├── AndMatcher.html │ │ │ │ ├── HasArgumentWithValue.html │ │ │ │ ├── HasNestedPropertyWithValue.html │ │ │ │ ├── LambdaJMatcher.html │ │ │ │ ├── OrMatcher.html │ │ │ │ ├── Predicate.html │ │ │ │ ├── class-use │ │ │ │ ├── AndMatcher.html │ │ │ │ ├── HasArgumentWithValue.html │ │ │ │ ├── HasNestedPropertyWithValue.html │ │ │ │ ├── LambdaJMatcher.html │ │ │ │ ├── OrMatcher.html │ │ │ │ └── Predicate.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ └── package-use.html │ │ │ ├── group │ │ │ ├── ArgumentGroupCondition.html │ │ │ ├── Group.html │ │ │ ├── GroupCondition.html │ │ │ ├── GroupConditions.html │ │ │ ├── GroupItem.html │ │ │ ├── Groups.html │ │ │ ├── StringGroupCondition.html │ │ │ ├── class-use │ │ │ │ ├── ArgumentGroupCondition.html │ │ │ │ ├── Group.html │ │ │ │ ├── GroupCondition.html │ │ │ │ ├── GroupConditions.html │ │ │ │ ├── GroupItem.html │ │ │ │ ├── Groups.html │ │ │ │ └── StringGroupCondition.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ ├── package-use.html │ │ │ ├── proxy │ │ │ ├── InvocationInterceptor.html │ │ │ ├── ProxyIterator.html │ │ │ ├── ProxyUtil.html │ │ │ ├── UnproxableClassException.html │ │ │ ├── class-use │ │ │ │ ├── InvocationInterceptor.html │ │ │ │ ├── ProxyIterator.html │ │ │ │ ├── ProxyUtil.html │ │ │ │ └── UnproxableClassException.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ │ └── util │ │ │ ├── IntrospectionException.html │ │ │ ├── IntrospectionUtil.html │ │ │ ├── NotUniqueItemException.html │ │ │ ├── class-use │ │ │ ├── IntrospectionException.html │ │ │ ├── IntrospectionUtil.html │ │ │ └── NotUniqueItemException.html │ │ │ ├── iterator │ │ │ ├── IteratorFactory.html │ │ │ ├── MatchingIterator.html │ │ │ ├── ResettableIterator.html │ │ │ ├── ResettableIteratorOnArray.html │ │ │ ├── ResettableIteratorOnIterable.html │ │ │ ├── ResettableIteratorOnIterator.html │ │ │ ├── class-use │ │ │ │ ├── IteratorFactory.html │ │ │ │ ├── MatchingIterator.html │ │ │ │ ├── ResettableIterator.html │ │ │ │ ├── ResettableIteratorOnArray.html │ │ │ │ ├── ResettableIteratorOnIterable.html │ │ │ │ └── ResettableIteratorOnIterator.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ ├── constant-values.html │ ├── deprecated-list.html │ ├── help-doc.html │ ├── index-all.html │ ├── index.html │ ├── overview-frame.html │ ├── overview-summary.html │ ├── overview-tree.html │ ├── package-list │ ├── resources │ │ ├── background.gif │ │ ├── tab.gif │ │ ├── titlebar.gif │ │ └── titlebar_end.gif │ ├── serialized-form.html │ └── stylesheet.css ├── cobertura │ ├── ch.lambdaj.Lambda.html │ ├── ch.lambdaj.collection.AbstractLambdaCollection.html │ ├── ch.lambdaj.collection.LambdaCollection.html │ ├── ch.lambdaj.collection.LambdaCollections.html │ ├── ch.lambdaj.collection.LambdaGroup.html │ ├── ch.lambdaj.collection.LambdaIterable.html │ ├── ch.lambdaj.collection.LambdaIterator.html │ ├── ch.lambdaj.collection.LambdaList.html │ ├── ch.lambdaj.collection.LambdaMap.html │ ├── ch.lambdaj.collection.LambdaSet.html │ ├── ch.lambdaj.function.aggregate.Aggregator.html │ ├── ch.lambdaj.function.aggregate.Avg.html │ ├── ch.lambdaj.function.aggregate.Chooser.html │ ├── ch.lambdaj.function.aggregate.ChooserOnArgument.html │ ├── ch.lambdaj.function.aggregate.Concat.html │ ├── ch.lambdaj.function.aggregate.InitializedPairAggregator.html │ ├── ch.lambdaj.function.aggregate.Max.html │ ├── ch.lambdaj.function.aggregate.MaxOnArgument.html │ ├── ch.lambdaj.function.aggregate.Min.html │ ├── ch.lambdaj.function.aggregate.MinOnArgument.html │ ├── ch.lambdaj.function.aggregate.PairAggregator.html │ ├── ch.lambdaj.function.aggregate.ProxyAggregator.html │ ├── ch.lambdaj.function.aggregate.Sum.html │ ├── ch.lambdaj.function.aggregate.SumDouble.html │ ├── ch.lambdaj.function.aggregate.SumInteger.html │ ├── ch.lambdaj.function.aggregate.SumLong.html │ ├── ch.lambdaj.function.argument.Argument.html │ ├── ch.lambdaj.function.argument.ArgumentConversionException.html │ ├── ch.lambdaj.function.argument.ArgumentsFactory.html │ ├── ch.lambdaj.function.argument.FinalClassArgumentCreator.html │ ├── ch.lambdaj.function.argument.Invocation.html │ ├── ch.lambdaj.function.argument.InvocationSequence.html │ ├── ch.lambdaj.function.argument.Invoker.html │ ├── ch.lambdaj.function.argument.InvokerJitter.html │ ├── ch.lambdaj.function.argument.ProxyArgument.html │ ├── ch.lambdaj.function.closure.AbstractClosure.html │ ├── ch.lambdaj.function.closure.Closure.html │ ├── ch.lambdaj.function.closure.Closure0.html │ ├── ch.lambdaj.function.closure.Closure1.html │ ├── ch.lambdaj.function.closure.Closure2.html │ ├── ch.lambdaj.function.closure.Closure3.html │ ├── ch.lambdaj.function.closure.Closure4.html │ ├── ch.lambdaj.function.closure.ClosureResult.html │ ├── ch.lambdaj.function.closure.ClosuresFactory.html │ ├── ch.lambdaj.function.closure.DelayedClosure.html │ ├── ch.lambdaj.function.closure.Invokable.html │ ├── ch.lambdaj.function.closure.InvokableConstructor.html │ ├── ch.lambdaj.function.closure.InvokableMethod.html │ ├── ch.lambdaj.function.closure.ProxyClosure.html │ ├── ch.lambdaj.function.closure.Switcher.html │ ├── ch.lambdaj.function.closure.WrongClosureInvocationException.html │ ├── ch.lambdaj.function.compare.ArgumentComparator.html │ ├── ch.lambdaj.function.compare.ComparatorUtil.html │ ├── ch.lambdaj.function.compare.PropertyComparator.html │ ├── ch.lambdaj.function.convert.AliasedArgumentConverter.html │ ├── ch.lambdaj.function.convert.ArgumentConverter.html │ ├── ch.lambdaj.function.convert.ConstructorArgumentConverter.html │ ├── ch.lambdaj.function.convert.Converter.html │ ├── ch.lambdaj.function.convert.ConverterIterator.html │ ├── ch.lambdaj.function.convert.DefaultStringConverter.html │ ├── ch.lambdaj.function.convert.ProjectConverter.html │ ├── ch.lambdaj.function.convert.PropertyExtractor.html │ ├── ch.lambdaj.function.convert.StringConverter.html │ ├── ch.lambdaj.function.convert.StringLengthConverter.html │ ├── ch.lambdaj.function.convert.StringPropertyExtractor.html │ ├── ch.lambdaj.function.matcher.AndMatcher.html │ ├── ch.lambdaj.function.matcher.HasArgumentWithValue.html │ ├── ch.lambdaj.function.matcher.HasNestedPropertyWithValue.html │ ├── ch.lambdaj.function.matcher.LambdaJMatcher.html │ ├── ch.lambdaj.function.matcher.OrMatcher.html │ ├── ch.lambdaj.function.matcher.Predicate.html │ ├── ch.lambdaj.group.ArgumentGroupCondition.html │ ├── ch.lambdaj.group.Group.html │ ├── ch.lambdaj.group.GroupComparator.html │ ├── ch.lambdaj.group.GroupCondition.html │ ├── ch.lambdaj.group.GroupConditions.html │ ├── ch.lambdaj.group.GroupImpl.html │ ├── ch.lambdaj.group.GroupItem.html │ ├── ch.lambdaj.group.Groups.html │ ├── ch.lambdaj.group.LeafGroup.html │ ├── ch.lambdaj.group.StringGroupCondition.html │ ├── ch.lambdaj.proxy.ClassImposterizer.html │ ├── ch.lambdaj.proxy.InvocationInterceptor.html │ ├── ch.lambdaj.proxy.ProxyIterator.html │ ├── ch.lambdaj.proxy.ProxyUtil.html │ ├── ch.lambdaj.proxy.UnproxableClassException.html │ ├── ch.lambdaj.util.IntrospectionException.html │ ├── ch.lambdaj.util.IntrospectionUtil.html │ ├── ch.lambdaj.util.NotUniqueItemException.html │ ├── ch.lambdaj.util.iterator.IteratorFactory.html │ ├── ch.lambdaj.util.iterator.MatchingIterator.html │ ├── ch.lambdaj.util.iterator.ResettableIterator.html │ ├── ch.lambdaj.util.iterator.ResettableIteratorOnArray.html │ ├── ch.lambdaj.util.iterator.ResettableIteratorOnIterable.html │ ├── ch.lambdaj.util.iterator.ResettableIteratorOnIterator.html │ ├── coverage.xml │ ├── css │ │ ├── help.css │ │ ├── main.css │ │ ├── sortabletable.css │ │ ├── source-viewer.css │ │ └── tooltip.css │ ├── frame-packages.html │ ├── frame-sourcefiles-ch.lambdaj.collection.html │ ├── frame-sourcefiles-ch.lambdaj.function.aggregate.html │ ├── frame-sourcefiles-ch.lambdaj.function.argument.html │ ├── frame-sourcefiles-ch.lambdaj.function.closure.html │ ├── frame-sourcefiles-ch.lambdaj.function.compare.html │ ├── frame-sourcefiles-ch.lambdaj.function.convert.html │ ├── frame-sourcefiles-ch.lambdaj.function.matcher.html │ ├── frame-sourcefiles-ch.lambdaj.group.html │ ├── frame-sourcefiles-ch.lambdaj.html │ ├── frame-sourcefiles-ch.lambdaj.proxy.html │ ├── frame-sourcefiles-ch.lambdaj.util.html │ ├── frame-sourcefiles-ch.lambdaj.util.iterator.html │ ├── frame-sourcefiles.html │ ├── frame-summary-ch.lambdaj.collection.html │ ├── frame-summary-ch.lambdaj.function.aggregate.html │ ├── frame-summary-ch.lambdaj.function.argument.html │ ├── frame-summary-ch.lambdaj.function.closure.html │ ├── frame-summary-ch.lambdaj.function.compare.html │ ├── frame-summary-ch.lambdaj.function.convert.html │ ├── frame-summary-ch.lambdaj.function.matcher.html │ ├── frame-summary-ch.lambdaj.group.html │ ├── frame-summary-ch.lambdaj.html │ ├── frame-summary-ch.lambdaj.proxy.html │ ├── frame-summary-ch.lambdaj.util.html │ ├── frame-summary-ch.lambdaj.util.iterator.html │ ├── frame-summary.html │ ├── help.html │ ├── images │ │ ├── blank.png │ │ ├── downsimple.png │ │ └── upsimple.png │ ├── index.html │ └── js │ │ ├── customsorttypes.js │ │ ├── popup.js │ │ ├── sortabletable.js │ │ └── stringbuilder.js ├── cpd.html ├── cpd.xml ├── css │ ├── maven-base.css │ ├── maven-theme.css │ ├── print.css │ └── site.css ├── dependencies.html ├── findbugs.html ├── images │ ├── close.gif │ ├── collapsed.gif │ ├── expanded.gif │ ├── external.png │ ├── icon_error_sml.gif │ ├── icon_info_sml.gif │ ├── icon_success_sml.gif │ ├── icon_warning_sml.gif │ ├── logos │ │ ├── build-by-maven-black.png │ │ ├── build-by-maven-white.png │ │ └── maven-feather.png │ └── newwindow.png ├── index.html ├── integration.html ├── issue-tracking.html ├── license.html ├── mail-lists.html ├── plugin-management.html ├── plugins.html ├── pmd.html ├── pmd.xml ├── project-info.html ├── project-reports.html ├── project-summary.html ├── source-repository.html ├── team-list.html └── testapidocs │ ├── allclasses-frame.html │ ├── allclasses-noframe.html │ ├── ch │ └── lambdaj │ │ ├── ArgumentCornerCaseTest.Interval.html │ │ ├── ArgumentCornerCaseTest.Intervals.html │ │ ├── ArgumentCornerCaseTest.html │ │ ├── Assert.html │ │ ├── ClosureSpecialCasesTest.html │ │ ├── ClosureTest.NonCommutativeDoer.html │ │ ├── ClosureTest.html │ │ ├── ClosureVoidMethodInvocationTest.html │ │ ├── ConstructorBugTest.html │ │ ├── DelayedClosureTest.html │ │ ├── LambdaTest.CostItem.html │ │ ├── LambdaTest.FinalPerson.html │ │ ├── LambdaTest.NoEmptyConstructorPerson.html │ │ ├── LambdaTest.html │ │ ├── MultithreadTestMain.SomeClass.html │ │ ├── MultithreadTestMain.html │ │ ├── PrimitiveReferenceTest.TestItem.html │ │ ├── PrimitiveReferenceTest.html │ │ ├── Strings.html │ │ ├── SwitcherTest.html │ │ ├── class-use │ │ ├── ArgumentCornerCaseTest.Interval.html │ │ ├── ArgumentCornerCaseTest.Intervals.html │ │ ├── ArgumentCornerCaseTest.html │ │ ├── Assert.html │ │ ├── ClosureSpecialCasesTest.html │ │ ├── ClosureTest.NonCommutativeDoer.html │ │ ├── ClosureTest.html │ │ ├── ClosureVoidMethodInvocationTest.html │ │ ├── ConstructorBugTest.html │ │ ├── DelayedClosureTest.html │ │ ├── LambdaTest.CostItem.html │ │ ├── LambdaTest.FinalPerson.html │ │ ├── LambdaTest.NoEmptyConstructorPerson.html │ │ ├── LambdaTest.html │ │ ├── MultithreadTestMain.SomeClass.html │ │ ├── MultithreadTestMain.html │ │ ├── PrimitiveReferenceTest.TestItem.html │ │ ├── PrimitiveReferenceTest.html │ │ ├── Strings.html │ │ └── SwitcherTest.html │ │ ├── collection │ │ ├── LambdaCollectionTest.html │ │ ├── LambdaCollectionsTest.NoEmptyConstructorPerson.html │ │ ├── LambdaCollectionsTest.html │ │ ├── LambdaGroupTest.html │ │ ├── LambdaIteratorTest.Premium.html │ │ ├── LambdaIteratorTest.html │ │ ├── LambdaListTest.NonCloneableList.html │ │ ├── LambdaListTest.Premium.html │ │ ├── LambdaListTest.html │ │ ├── LambdaMapTest.NonCloneableMap.html │ │ ├── LambdaMapTest.html │ │ ├── class-use │ │ │ ├── LambdaCollectionTest.html │ │ │ ├── LambdaCollectionsTest.NoEmptyConstructorPerson.html │ │ │ ├── LambdaCollectionsTest.html │ │ │ ├── LambdaGroupTest.html │ │ │ ├── LambdaIteratorTest.Premium.html │ │ │ ├── LambdaIteratorTest.html │ │ │ ├── LambdaListTest.NonCloneableList.html │ │ │ ├── LambdaListTest.Premium.html │ │ │ ├── LambdaListTest.html │ │ │ ├── LambdaMapTest.NonCloneableMap.html │ │ │ └── LambdaMapTest.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html │ │ ├── demo │ │ ├── Car.html │ │ ├── Db.html │ │ ├── LambdaDemoTest.html │ │ ├── LambdaDemoTestMain.html │ │ ├── LambdaListDemoTest.html │ │ ├── Person.html │ │ ├── Sale.html │ │ ├── TableMain.Bean.html │ │ ├── TableMain.html │ │ ├── Util.html │ │ ├── class-use │ │ │ ├── Car.html │ │ │ ├── Db.html │ │ │ ├── LambdaDemoTest.html │ │ │ ├── LambdaDemoTestMain.html │ │ │ ├── LambdaListDemoTest.html │ │ │ ├── Person.html │ │ │ ├── Sale.html │ │ │ ├── TableMain.Bean.html │ │ │ ├── TableMain.html │ │ │ └── Util.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html │ │ ├── function │ │ ├── aggregate │ │ │ ├── AggregateTest.Premium.html │ │ │ ├── AggregateTest.html │ │ │ ├── ConcatTest.html │ │ │ ├── MaxTest.html │ │ │ ├── Measure.html │ │ │ ├── MinTest.html │ │ │ ├── Money.MoneyAggregator.html │ │ │ ├── Money.html │ │ │ ├── SumTest.html │ │ │ ├── class-use │ │ │ │ ├── AggregateTest.Premium.html │ │ │ │ ├── AggregateTest.html │ │ │ │ ├── ConcatTest.html │ │ │ │ ├── MaxTest.html │ │ │ │ ├── Measure.html │ │ │ │ ├── MinTest.html │ │ │ │ ├── Money.MoneyAggregator.html │ │ │ │ ├── Money.html │ │ │ │ └── SumTest.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ ├── argument │ │ │ ├── ArgumentsFactoryTest.IntegerWrapper.html │ │ │ ├── ArgumentsFactoryTest.LocalDateArgumentCreator.html │ │ │ ├── ArgumentsFactoryTest.StringWrapper.html │ │ │ ├── ArgumentsFactoryTest.UnistatiableClass.html │ │ │ ├── ArgumentsFactoryTest.html │ │ │ ├── CreatingArgumentFromArrayTest.ICompilationUnit.html │ │ │ ├── CreatingArgumentFromArrayTest.IPackageFragment.html │ │ │ ├── CreatingArgumentFromArrayTest.html │ │ │ ├── InvocationSequenceTest.SimpleBrand.html │ │ │ ├── InvocationSequenceTest.html │ │ │ ├── class-use │ │ │ │ ├── ArgumentsFactoryTest.IntegerWrapper.html │ │ │ │ ├── ArgumentsFactoryTest.LocalDateArgumentCreator.html │ │ │ │ ├── ArgumentsFactoryTest.StringWrapper.html │ │ │ │ ├── ArgumentsFactoryTest.UnistatiableClass.html │ │ │ │ ├── ArgumentsFactoryTest.html │ │ │ │ ├── CreatingArgumentFromArrayTest.ICompilationUnit.html │ │ │ │ ├── CreatingArgumentFromArrayTest.IPackageFragment.html │ │ │ │ ├── CreatingArgumentFromArrayTest.html │ │ │ │ ├── InvocationSequenceTest.SimpleBrand.html │ │ │ │ └── InvocationSequenceTest.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ ├── closure │ │ │ ├── FaillingClosureTest.html │ │ │ ├── FileParserClosureTest.html │ │ │ ├── FileParserImplicitClosureTest.html │ │ │ ├── class-use │ │ │ │ ├── FaillingClosureTest.html │ │ │ │ ├── FileParserClosureTest.html │ │ │ │ └── FileParserImplicitClosureTest.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ └── matcher │ │ │ ├── HasArgumentWithValueTest.html │ │ │ ├── HasNestedPropertyWithValueTest.html │ │ │ ├── class-use │ │ │ ├── HasArgumentWithValueTest.html │ │ │ └── HasNestedPropertyWithValueTest.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ ├── group │ │ ├── GroupByTest.html │ │ ├── GroupsTest.html │ │ ├── TypedGroupByTest.html │ │ ├── class-use │ │ │ ├── GroupByTest.html │ │ │ ├── GroupsTest.html │ │ │ └── TypedGroupByTest.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html │ │ ├── mock │ │ ├── Exposure.html │ │ ├── ExposureBy.html │ │ ├── IPerson.Gender.html │ │ ├── IPerson.html │ │ ├── Person.html │ │ ├── PersonDto.html │ │ ├── PersonThrowingException.html │ │ ├── ReturnAString.html │ │ ├── Text.html │ │ ├── ValidatingPersonDto.html │ │ ├── class-use │ │ │ ├── Exposure.html │ │ │ ├── ExposureBy.html │ │ │ ├── IPerson.Gender.html │ │ │ ├── IPerson.html │ │ │ ├── Person.html │ │ │ ├── PersonDto.html │ │ │ ├── PersonThrowingException.html │ │ │ ├── ReturnAString.html │ │ │ ├── Text.html │ │ │ └── ValidatingPersonDto.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ ├── package-use.html │ │ ├── proxy │ │ └── nodefconstructor │ │ │ ├── ElementId.html │ │ │ ├── ProxyNoDefaultConstructorTest.html │ │ │ ├── RelationMetricResult.html │ │ │ ├── class-use │ │ │ ├── ElementId.html │ │ │ ├── ProxyNoDefaultConstructorTest.html │ │ │ └── RelationMetricResult.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ ├── package-use.html │ │ │ └── problem │ │ │ ├── ElementId.html │ │ │ ├── RelationSmell.html │ │ │ ├── RelationSmellQuery.html │ │ │ ├── class-use │ │ │ ├── ElementId.html │ │ │ ├── RelationSmell.html │ │ │ └── RelationSmellQuery.html │ │ │ ├── package-frame.html │ │ │ ├── package-summary.html │ │ │ ├── package-tree.html │ │ │ └── package-use.html │ │ └── util │ │ └── iterator │ │ ├── IteratorFactoryTest.html │ │ ├── class-use │ │ └── IteratorFactoryTest.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ ├── package-tree.html │ │ └── package-use.html │ ├── constant-values.html │ ├── deprecated-list.html │ ├── help-doc.html │ ├── index-all.html │ ├── index.html │ ├── overview-frame.html │ ├── overview-summary.html │ ├── overview-tree.html │ ├── package-list │ ├── resources │ ├── background.gif │ ├── tab.gif │ ├── titlebar.gif │ └── titlebar_end.gif │ ├── serialized-form.html │ └── stylesheet.css ├── pom.xml └── src ├── main ├── Main.iml └── java │ └── ch │ └── lambdaj │ ├── Lambda.java │ ├── collection │ ├── AbstractLambdaCollection.java │ ├── LambdaCollection.java │ ├── LambdaCollections.java │ ├── LambdaGroup.java │ ├── LambdaIterable.java │ ├── LambdaIterator.java │ ├── LambdaList.java │ ├── LambdaMap.java │ └── LambdaSet.java │ ├── function │ ├── aggregate │ │ ├── Aggregator.java │ │ ├── Avg.java │ │ ├── Chooser.java │ │ ├── ChooserOnArgument.java │ │ ├── Concat.java │ │ ├── InitializedPairAggregator.java │ │ ├── Max.java │ │ ├── MaxOnArgument.java │ │ ├── Min.java │ │ ├── MinOnArgument.java │ │ ├── PairAggregator.java │ │ ├── ProxyAggregator.java │ │ ├── Sum.java │ │ ├── SumDouble.java │ │ ├── SumInteger.java │ │ └── SumLong.java │ ├── argument │ │ ├── Argument.java │ │ ├── ArgumentConversionException.java │ │ ├── ArgumentsFactory.java │ │ ├── FinalClassArgumentCreator.java │ │ ├── Invocation.java │ │ ├── InvocationSequence.java │ │ ├── Invoker.java │ │ ├── InvokerJitter.java │ │ └── ProxyArgument.java │ ├── closure │ │ ├── AbstractClosure.java │ │ ├── Closure.java │ │ ├── Closure0.java │ │ ├── Closure1.java │ │ ├── Closure2.java │ │ ├── Closure3.java │ │ ├── Closure4.java │ │ ├── ClosureResult.java │ │ ├── ClosuresFactory.java │ │ ├── DelayedClosure.java │ │ ├── Invokable.java │ │ ├── InvokableConstructor.java │ │ ├── InvokableMethod.java │ │ ├── ProxyClosure.java │ │ ├── Switcher.java │ │ └── WrongClosureInvocationException.java │ ├── compare │ │ ├── ArgumentComparator.java │ │ ├── ComparatorUtil.java │ │ └── PropertyComparator.java │ ├── convert │ │ ├── AliasedArgumentConverter.java │ │ ├── ArgumentConverter.java │ │ ├── ConstructorArgumentConverter.java │ │ ├── Converter.java │ │ ├── ConverterIterator.java │ │ ├── DefaultStringConverter.java │ │ ├── ProjectConverter.java │ │ ├── PropertyExtractor.java │ │ ├── StringConverter.java │ │ ├── StringLengthConverter.java │ │ └── StringPropertyExtractor.java │ └── matcher │ │ ├── AndMatcher.java │ │ ├── HasArgumentWithValue.java │ │ ├── HasNestedPropertyWithValue.java │ │ ├── LambdaJMatcher.java │ │ ├── OrMatcher.java │ │ └── Predicate.java │ ├── group │ ├── ArgumentGroupCondition.java │ ├── Group.java │ ├── GroupComparator.java │ ├── GroupCondition.java │ ├── GroupConditions.java │ ├── GroupImpl.java │ ├── GroupItem.java │ ├── Groups.java │ ├── LeafGroup.java │ └── StringGroupCondition.java │ ├── proxy │ ├── ClassImposterizer.java │ ├── InvocationInterceptor.java │ ├── ProxyIterator.java │ ├── ProxyUtil.java │ └── UnproxableClassException.java │ └── util │ ├── IntrospectionException.java │ ├── IntrospectionUtil.java │ ├── NotUniqueItemException.java │ └── iterator │ ├── IteratorFactory.java │ ├── MatchingIterator.java │ ├── ResettableIterator.java │ ├── ResettableIteratorOnArray.java │ ├── ResettableIteratorOnIterable.java │ └── ResettableIteratorOnIterator.java └── test ├── Test.iml ├── java └── ch │ └── lambdaj │ ├── ArgumentCornerCaseTest.java │ ├── Assert.java │ ├── ClosureSpecialCasesTest.java │ ├── ClosureTest.java │ ├── ClosureVoidMethodInvocationTest.java │ ├── ConstructorBugTest.java │ ├── DelayedClosureTest.java │ ├── LambdaTest.java │ ├── MultithreadTestMain.java │ ├── PrimitiveReferenceTest.java │ ├── Strings.java │ ├── SwitcherTest.java │ ├── collection │ ├── LambdaCollectionTest.java │ ├── LambdaCollectionsTest.java │ ├── LambdaGroupTest.java │ ├── LambdaIteratorTest.java │ ├── LambdaListTest.java │ └── LambdaMapTest.java │ ├── demo │ ├── Car.java │ ├── Db.java │ ├── LambdaDemoTest.java │ ├── LambdaDemoTestMain.java │ ├── LambdaListDemoTest.java │ ├── Person.java │ ├── Sale.java │ ├── TableMain.java │ └── Util.java │ ├── function │ ├── aggregate │ │ ├── AggregateTest.java │ │ ├── ConcatTest.java │ │ ├── MaxTest.java │ │ ├── Measure.java │ │ ├── MinTest.java │ │ ├── Money.java │ │ └── SumTest.java │ ├── argument │ │ ├── ArgumentsFactoryTest.java │ │ ├── CreatingArgumentFromArrayTest.java │ │ └── InvocationSequenceTest.java │ ├── closure │ │ ├── FaillingClosureTest.java │ │ ├── FileParserClosureTest.java │ │ └── FileParserImplicitClosureTest.java │ └── matcher │ │ ├── HasArgumentWithValueTest.java │ │ └── HasNestedPropertyWithValueTest.java │ ├── group │ ├── GroupByTest.java │ ├── GroupsTest.java │ └── TypedGroupByTest.java │ ├── mock │ ├── Exposure.java │ ├── ExposureBy.java │ ├── IPerson.java │ ├── Person.java │ ├── PersonDto.java │ ├── PersonThrowingException.java │ ├── ReturnAString.java │ ├── Text.java │ └── ValidatingPersonDto.java │ ├── proxy │ └── nodefconstructor │ │ ├── ElementId.java │ │ ├── ProxyNoDefaultConstructorTest.java │ │ ├── RelationMetricResult.java │ │ └── problem │ │ ├── ElementId.java │ │ ├── RelationSmell.java │ │ └── RelationSmellQuery.java │ └── util │ └── iterator │ └── IteratorFactoryTest.java └── resources └── commedia.txt /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /local 3 | 4 | # Eclipse, Netbeans and IntelliJ files 5 | /.* 6 | !.gitignore 7 | /nbproject 8 | /*.ipr 9 | /*.iws 10 | /*.iml 11 | 12 | # Repository wide ignore mac DS_Store files 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /LambdajDemoTest.bat: -------------------------------------------------------------------------------- 1 | set MAVEN_REPO=C:\Users\Mario\.m2\repository 2 | 3 | java -server -Xms512M -Xmx512M -cp %MAVEN_REPO%/cglib/cglib-nodep/2.2.2/cglib-nodep-2.2.2.jar;%MAVEN_REPO%/org/hamcrest/hamcrest-all/1.1/hamcrest-all-1.1.jar;%MAVEN_REPO%/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar;%MAVEN_REPO%/org/objenesis/objenesis/1.2/objenesis-1.2.jar;target/classes;target/test-classes ch.lambdaj.demo.LambdaDemoTestMain %1 -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/README -------------------------------------------------------------------------------- /html/apidocs/ch/lambdaj/collection/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.collection (lambdaj 2.4-SNAPSHOT API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.collection

13 |
14 |

Classes

15 | 25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /html/apidocs/ch/lambdaj/function/argument/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.function.argument (lambdaj 2.4-SNAPSHOT API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.function.argument

13 |
14 |

Interfaces

15 | 19 |

Classes

20 | 24 |

Exceptions

25 | 28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /html/apidocs/ch/lambdaj/function/closure/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.function.closure (lambdaj 2.4-SNAPSHOT API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.function.closure

13 |
14 |

Interfaces

15 | 18 |

Classes

19 | 30 |

Exceptions

31 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /html/apidocs/ch/lambdaj/function/compare/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.function.compare (lambdaj 2.4-SNAPSHOT API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.function.compare

13 |
14 |

Classes

15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /html/apidocs/ch/lambdaj/function/convert/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.function.convert (lambdaj 2.4-SNAPSHOT API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.function.convert

13 |
14 |

Interfaces

15 | 19 |

Classes

20 | 31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /html/apidocs/ch/lambdaj/function/matcher/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.function.matcher (lambdaj 2.4-SNAPSHOT API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.function.matcher

13 |
14 |

Classes

15 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /html/apidocs/ch/lambdaj/group/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.group (lambdaj 2.4-SNAPSHOT API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.group

13 |
14 |

Interfaces

15 | 18 |

Classes

19 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /html/apidocs/ch/lambdaj/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj (lambdaj 2.4-SNAPSHOT API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj

13 |
14 |

Classes

15 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /html/apidocs/ch/lambdaj/proxy/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.proxy (lambdaj 2.4-SNAPSHOT API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.proxy

13 |
14 |

Classes

15 | 20 |

Exceptions

21 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /html/apidocs/ch/lambdaj/util/iterator/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.util.iterator (lambdaj 2.4-SNAPSHOT API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.util.iterator

13 |
14 |

Classes

15 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /html/apidocs/ch/lambdaj/util/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.util (lambdaj 2.4-SNAPSHOT API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.util

13 |
14 |

Classes

15 | 18 |

Exceptions

19 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /html/apidocs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | lambdaj 2.4-SNAPSHOT API 8 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | <noscript> 28 | <div>JavaScript is disabled on your browser.</div> 29 | </noscript> 30 | <h2>Frame Alert</h2> 31 | <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p> 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /html/apidocs/overview-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Overview List (lambdaj 2.4-SNAPSHOT API) 8 | 9 | 10 | 11 | 12 |
All Classes
13 |
14 |

Packages

15 | 29 |
30 |

 

31 | 32 | 33 | -------------------------------------------------------------------------------- /html/apidocs/package-list: -------------------------------------------------------------------------------- 1 | ch.lambdaj 2 | ch.lambdaj.collection 3 | ch.lambdaj.function.aggregate 4 | ch.lambdaj.function.argument 5 | ch.lambdaj.function.closure 6 | ch.lambdaj.function.compare 7 | ch.lambdaj.function.convert 8 | ch.lambdaj.function.matcher 9 | ch.lambdaj.group 10 | ch.lambdaj.proxy 11 | ch.lambdaj.util 12 | ch.lambdaj.util.iterator 13 | -------------------------------------------------------------------------------- /html/apidocs/resources/background.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/apidocs/resources/background.gif -------------------------------------------------------------------------------- /html/apidocs/resources/tab.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/apidocs/resources/tab.gif -------------------------------------------------------------------------------- /html/apidocs/resources/titlebar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/apidocs/resources/titlebar.gif -------------------------------------------------------------------------------- /html/apidocs/resources/titlebar_end.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/apidocs/resources/titlebar_end.gif -------------------------------------------------------------------------------- /html/cobertura/css/help.css: -------------------------------------------------------------------------------- 1 | dl { 2 | float: left; 3 | width: 100%; 4 | } 5 | 6 | dt { 7 | border-top: 1px solid #808080; 8 | float: left; 9 | font-weight: bold; 10 | margin: 0; 11 | padding: 1em; 12 | width: 20%; 13 | } 14 | 15 | dd { 16 | border-top: 1px solid #808080; 17 | float: left; 18 | font-style: italic; 19 | margin: 0; 20 | padding: 1em; 21 | width: 60%; 22 | } 23 | -------------------------------------------------------------------------------- /html/cobertura/css/main.css: -------------------------------------------------------------------------------- 1 | @import url("help.css"); 2 | @import url("source-viewer.css"); 3 | @import url("tooltip.css"); 4 | 5 | .hidden { 6 | display: none; 7 | } 8 | 9 | a.dfn { 10 | border-bottom: 1px dotted #00aa00; 11 | cursor: help; 12 | } 13 | 14 | a.dfn:active, a.dfn:link, a.dfn:visited { 15 | color: #000000; 16 | text-decoration: none; 17 | } 18 | 19 | a.dfn:hover { 20 | color: #0000ff; 21 | text-decoration: none; 22 | } 23 | 24 | body { 25 | font-family: verdana, arial, helvetica; 26 | } 27 | 28 | h1, h2, h3, h4, h5, h6 { 29 | margin-bottom: 0.5em; 30 | } 31 | 32 | h5 { 33 | margin-top: 0.5em; 34 | } 35 | 36 | div.footer { 37 | font-size: 68%; 38 | margin-top: 1.5em; 39 | } 40 | 41 | div.percentgraph 42 | { 43 | background-color: #f02020; 44 | border: #808080 1px solid; 45 | height: 1.3em; 46 | margin: 0px; 47 | padding: 0px; 48 | width: 100px; 49 | } 50 | 51 | div.percentgraph div.greenbar 52 | { 53 | background-color: #00f000; 54 | height: 1.3em; 55 | margin: 0px; 56 | padding: 0px; 57 | } 58 | 59 | div.percentgraph div.na 60 | { 61 | background-color: #eaeaea; 62 | height: 1.3em; 63 | margin: 0px; 64 | padding: 0px; 65 | } 66 | 67 | div.percentgraph span.text 68 | { 69 | display: block; 70 | position: absolute; 71 | text-align: center; 72 | width: 100px; 73 | } 74 | 75 | div.separator { 76 | height: 10px; 77 | } 78 | 79 | table tr td, table tr th { 80 | font-size: 68%; 81 | } 82 | 83 | td.value table tr td { 84 | font-size: 11px; 85 | } 86 | 87 | table.percentgraph { 88 | border: 0px; 89 | font-size: 130%; 90 | margin: 0px; 91 | margin-left: auto; 92 | margin-right: 0px; 93 | padding: 0px; 94 | } 95 | 96 | table.percentgraph tr.percentgraph { 97 | border: 0px; 98 | margin: 0px; 99 | padding: 0px; 100 | } 101 | 102 | table.percentgraph td.percentgraph { 103 | border: 0px; 104 | margin: 0px; 105 | padding: 0px; 106 | padding-left: 4px; 107 | } 108 | 109 | table.report { 110 | border-collapse: collapse; 111 | width: 100%; 112 | } 113 | 114 | table.report td { 115 | border: #d0d0d0 1px solid; 116 | } 117 | 118 | table.report td.heading { 119 | background: #dcecff; 120 | font-weight: bold; 121 | text-align: center; 122 | } 123 | 124 | table.report td.heading:hover { 125 | background: #c0ffc0; 126 | cursor: pointer; 127 | } 128 | 129 | table.report td.value { 130 | text-align: right; 131 | } 132 | -------------------------------------------------------------------------------- /html/cobertura/css/sortabletable.css: -------------------------------------------------------------------------------- 1 | .sort-table { 2 | font: Icon; 3 | border: 1px Solid ThreeDShadow; 4 | background: Window; 5 | color: WindowText; 6 | } 7 | 8 | .sort-table thead { 9 | background: ButtonFace; 10 | } 11 | 12 | .sort-table td { 13 | padding: 2px 5px; 14 | } 15 | 16 | .sort-table thead td { 17 | border: 1px solid; 18 | border-color: ButtonHighlight ButtonShadow 19 | ButtonShadow ButtonHighlight; 20 | cursor: default; 21 | } 22 | 23 | .sort-table thead td:active { 24 | border-color: ButtonShadow ButtonHighlight 25 | ButtonHighlight ButtonShadow; 26 | padding: 3px 4px 1px 6px; 27 | } 28 | 29 | .sort-table thead td[_sortType=None]:active { 30 | border-color: ButtonHighlight ButtonShadow 31 | ButtonShadow ButtonHighlight; 32 | padding: 2px 5px; 33 | } 34 | 35 | .sort-arrow { 36 | width: 11px; 37 | height: 11px; 38 | background-position: center center; 39 | background-repeat: no-repeat; 40 | margin: 0 2px; 41 | } 42 | 43 | .sort-arrow.descending { 44 | background-image: url("../images/downsimple.png"); 45 | 46 | } 47 | 48 | .sort-arrow.ascending { 49 | background-image: url("../images/upsimple.png"); 50 | } -------------------------------------------------------------------------------- /html/cobertura/css/source-viewer.css: -------------------------------------------------------------------------------- 1 | pre.src { 2 | background: #ffffff; 3 | margin-top: 0px; 4 | margin-bottom: 0px; 5 | } 6 | 7 | table.src { 8 | border: #dcdcdc 1px solid; 9 | font-size: 16px; 10 | } 11 | 12 | td.numLine { 13 | background: #f0f0f0; 14 | border-right: #dcdcdc 1px solid; 15 | padding-right: 3px; 16 | text-align: right; 17 | } 18 | 19 | td.numLineCover { 20 | background: #80ff80; 21 | border-right: #dcdcdc 1px solid; 22 | padding-right: 3px; 23 | text-align: right; 24 | } 25 | 26 | td.nbHits { 27 | background: #f0f0f0; 28 | border-right: #dcdcdc 1px solid; 29 | padding-right: 3px; 30 | text-align: right; 31 | } 32 | 33 | td.nbHitsCovered { 34 | background: #80ff80; 35 | border-right: #dcdcdc 1px solid; 36 | padding-right: 3px; 37 | text-align: right; 38 | } 39 | 40 | td.nbHitsUncovered { 41 | background: #ff9090; 42 | border-right: #dcdcdc 1px solid; 43 | font-weight: bold; 44 | padding-right: 3px; 45 | text-align: right; 46 | } 47 | 48 | td.src { 49 | width: 100%; 50 | } 51 | 52 | span.comment { 53 | color: #b22222; 54 | font-style: italic; 55 | } 56 | 57 | span.keyword { 58 | color: #2020bf; 59 | font-weight: bold; 60 | } 61 | 62 | span.srcUncovered { 63 | background: #ff9090; 64 | } 65 | 66 | span.string { 67 | color: #2a00ff; 68 | } 69 | 70 | span.text_italic { 71 | font-size: 12px; 72 | font-style: italic; 73 | } 74 | -------------------------------------------------------------------------------- /html/cobertura/css/tooltip.css: -------------------------------------------------------------------------------- 1 | a.hastooltip { 2 | border-bottom: 1px dotted #00aa00; 3 | color: #000000; 4 | cursor: help; 5 | font-style: normal; 6 | position: relative; /* This is the key */ 7 | text-decoration: none; 8 | z-index: 24; /* What does this do? */ 9 | } 10 | 11 | a.hastooltip:active { 12 | color: #000000; 13 | text-decoration: none; 14 | } 15 | 16 | a.hastooltip:link { 17 | color: #000000; 18 | text-decoration: none; 19 | } 20 | 21 | a.hastooltip:hover { 22 | background-color: #a0b8ff; 23 | color: #000000; 24 | text-decoration: none; 25 | z-index: 25; 26 | } 27 | 28 | a.hastooltip:visited { 29 | color: #000000; 30 | text-decoration: none; 31 | } 32 | 33 | a.hastooltip span { 34 | display: none; 35 | } 36 | 37 | a.hastooltip:hover span { 38 | background-color: #eeeeee; 39 | border: 1px solid #000000; 40 | color: #000000; 41 | display: block; 42 | padding: 5px; 43 | left: -15.2em; 44 | position: absolute; 45 | text-align: center; 46 | text-decoration: none; 47 | top: 2em; 48 | width: 20em; 49 | } 50 | -------------------------------------------------------------------------------- /html/cobertura/frame-sourcefiles-ch.lambdaj.collection.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Coverage Report Classes 7 | 8 | 9 | 10 |
11 | ch.lambdaj.collection 12 |
13 |
 
14 |
Classes
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
AbstractLambdaCollection (90%)
LambdaCollection (92%)
LambdaCollections (87%)
LambdaGroup (94%)
LambdaIterable (96%)
LambdaIterator (80%)
LambdaList (93%)
LambdaMap (97%)
LambdaSet (88%)
46 | 47 | 48 | -------------------------------------------------------------------------------- /html/cobertura/frame-sourcefiles-ch.lambdaj.function.argument.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Coverage Report Classes 7 | 8 | 9 | 10 |
11 | ch.lambdaj.function.argument 12 |
13 |
 
14 |
Classes
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
Argument (90%)
ArgumentConversionException (100%)
ArgumentsFactory (97%)
FinalClassArgumentCreator (N/A)
Invocation (100%)
InvocationSequence (100%)
Invoker (N/A)
InvokerJitter (73%)
ProxyArgument (100%)
46 | 47 | 48 | -------------------------------------------------------------------------------- /html/cobertura/frame-sourcefiles-ch.lambdaj.function.compare.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Coverage Report Classes 7 | 8 | 9 | 10 |
11 | ch.lambdaj.function.compare 12 |
13 |
 
14 |
Classes
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
ArgumentComparator (100%)
ComparatorUtil (92%)
PropertyComparator (100%)
28 | 29 | 30 | -------------------------------------------------------------------------------- /html/cobertura/frame-sourcefiles-ch.lambdaj.function.convert.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Coverage Report Classes 7 | 8 | 9 | 10 |
11 | ch.lambdaj.function.convert 12 |
13 |
 
14 |
Classes
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
AliasedArgumentConverter (92%)
ArgumentConverter (100%)
ConstructorArgumentConverter (100%)
Converter (N/A)
ConverterIterator (75%)
DefaultStringConverter (100%)
ProjectConverter (100%)
PropertyExtractor (100%)
StringConverter (N/A)
StringLengthConverter (100%)
StringPropertyExtractor (100%)
52 | 53 | 54 | -------------------------------------------------------------------------------- /html/cobertura/frame-sourcefiles-ch.lambdaj.function.matcher.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Coverage Report Classes 7 | 8 | 9 | 10 |
11 | ch.lambdaj.function.matcher 12 |
13 |
 
14 |
Classes
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
AndMatcher (100%)
HasArgumentWithValue (95%)
HasNestedPropertyWithValue (85%)
LambdaJMatcher (75%)
OrMatcher (100%)
Predicate (85%)
37 | 38 | 39 | -------------------------------------------------------------------------------- /html/cobertura/frame-sourcefiles-ch.lambdaj.group.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Coverage Report Classes 7 | 8 | 9 | 10 |
11 | ch.lambdaj.group 12 |
13 |
 
14 |
Classes
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |
ArgumentGroupCondition (92%)
Group (N/A)
GroupComparator (100%)
GroupCondition (100%)
GroupConditions (100%)
GroupImpl (100%)
GroupItem (89%)
Groups (93%)
LeafGroup (89%)
StringGroupCondition (100%)
49 | 50 | 51 | -------------------------------------------------------------------------------- /html/cobertura/frame-sourcefiles-ch.lambdaj.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Coverage Report Classes 7 | 8 | 9 | 10 |
11 | ch.lambdaj 12 |
13 |
 
14 |
Classes
15 | 16 | 17 | 18 | 19 | 20 | 21 |
Lambda (98%)
22 | 23 | 24 | -------------------------------------------------------------------------------- /html/cobertura/frame-sourcefiles-ch.lambdaj.proxy.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Coverage Report Classes 7 | 8 | 9 | 10 |
11 | ch.lambdaj.proxy 12 |
13 |
 
14 |
Classes
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
ClassImposterizer (91%)
InvocationInterceptor (100%)
ProxyIterator (88%)
ProxyUtil (96%)
UnproxableClassException (100%)
34 | 35 | 36 | -------------------------------------------------------------------------------- /html/cobertura/frame-sourcefiles-ch.lambdaj.util.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Coverage Report Classes 7 | 8 | 9 | 10 |
11 | ch.lambdaj.util 12 |
13 |
 
14 |
Classes
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
IntrospectionException (100%)
IntrospectionUtil (93%)
NotUniqueItemException (100%)
28 | 29 | 30 | -------------------------------------------------------------------------------- /html/cobertura/frame-sourcefiles-ch.lambdaj.util.iterator.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Coverage Report Classes 7 | 8 | 9 | 10 |
11 | ch.lambdaj.util.iterator 12 |
13 |
 
14 |
Classes
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
IteratorFactory (96%)
MatchingIterator (100%)
ResettableIterator (100%)
ResettableIteratorOnArray (100%)
ResettableIteratorOnIterable (100%)
ResettableIteratorOnIterator (100%)
37 | 38 | 39 | -------------------------------------------------------------------------------- /html/cobertura/help.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | Coverage Report - Help 9 | 10 | 11 | 12 | 13 |
14 | 15 |
Line Coverage
16 |
The percent of lines executed by this test run.
17 | 18 |
Branch Coverage
19 |
The percent of branches executed by this test run.
20 | 21 |
Complexity
22 |
Average McCabe's cyclomatic code complexity for all methods. This is basically a count of the number of different code paths in a method (incremented by 1 for each if statement, while loop, etc.)
23 | 24 |
N/A
25 |
Line coverage and branch coverage will appear as "Not Applicable" when Cobertura can not find line number information in the .class file. This happens for stub and skeleton classes, interfaces, or when the class was not compiled with "debug=true."
26 | 27 |
28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /html/cobertura/images/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/cobertura/images/blank.png -------------------------------------------------------------------------------- /html/cobertura/images/downsimple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/cobertura/images/downsimple.png -------------------------------------------------------------------------------- /html/cobertura/images/upsimple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/cobertura/images/upsimple.png -------------------------------------------------------------------------------- /html/cobertura/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | Coverage Report 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | <body> 19 | <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a frame-incapable web client.</p> 20 | <p><a href="frame-summary.html">Click here to view a non-frame version.</a></p> 21 | </body> 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /html/cobertura/js/customsorttypes.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Cobertura - http://cobertura.sourceforge.net/ 3 | * 4 | * Copyright (C) 2005 Mark Doliner 5 | * Copyright (C) 2005 Olivier Parent 6 | * 7 | * Cobertura is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published 9 | * by the Free Software Foundation; either version 2 of the License, 10 | * or (at your option) any later version. 11 | * 12 | * Cobertura is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with Cobertura; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | */ 22 | 23 | 24 | 25 | function percentageSortType( s ) 26 | { 27 | var ret; 28 | var i = s.indexOf( "%" ); 29 | 30 | if (i != -1) { 31 | s = s.substr( 0, i ); 32 | } 33 | ret = parseFloat(s); 34 | if (isNaN(ret)) { 35 | ret = -1; 36 | } 37 | 38 | return ret; 39 | } 40 | 41 | SortableTable.prototype.addSortType( "Percentage", percentageSortType ); 42 | 43 | 44 | 45 | // This is needed for correctly sorting numbers in different 46 | // locales. The stock number converter only expects to sort 47 | // numbers which use a period as a separator instead of a 48 | // comma (like French). 49 | function formattedNumberSortType( s ) 50 | { 51 | var ret; 52 | var i = s.indexOf(';'); 53 | 54 | if (i != -1) { 55 | s = s.substring(0, i); 56 | } 57 | ret = parseFloat(s); 58 | if (isNaN(ret)) { 59 | return -1; 60 | } 61 | 62 | return ret; 63 | } 64 | 65 | SortableTable.prototype.addSortType( "FormattedNumber", formattedNumberSortType ); 66 | -------------------------------------------------------------------------------- /html/cobertura/js/popup.js: -------------------------------------------------------------------------------- 1 | var newwindow; 2 | function popupwindow(url) 3 | { 4 | newwindow=window.open(url,'name','height=500,width=500,resizable=yes,scrollbars=yes'); 5 | if (window.focus) { 6 | newwindow.focus() 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /html/cpd.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /html/css/print.css: -------------------------------------------------------------------------------- 1 | #banner, #footer, #leftcol, #breadcrumbs, .docs #toc, .docs .courtesylinks, #leftColumn, #navColumn { 2 | display: none !important; 3 | } 4 | #bodyColumn, body.docs div.docs { 5 | margin: 0 !important; 6 | border: none !important 7 | } 8 | -------------------------------------------------------------------------------- /html/css/site.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/css/site.css -------------------------------------------------------------------------------- /html/images/close.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/images/close.gif -------------------------------------------------------------------------------- /html/images/collapsed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/images/collapsed.gif -------------------------------------------------------------------------------- /html/images/expanded.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/images/expanded.gif -------------------------------------------------------------------------------- /html/images/external.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/images/external.png -------------------------------------------------------------------------------- /html/images/icon_error_sml.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/images/icon_error_sml.gif -------------------------------------------------------------------------------- /html/images/icon_info_sml.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/images/icon_info_sml.gif -------------------------------------------------------------------------------- /html/images/icon_success_sml.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/images/icon_success_sml.gif -------------------------------------------------------------------------------- /html/images/icon_warning_sml.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/images/icon_warning_sml.gif -------------------------------------------------------------------------------- /html/images/logos/build-by-maven-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/images/logos/build-by-maven-black.png -------------------------------------------------------------------------------- /html/images/logos/build-by-maven-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/images/logos/build-by-maven-white.png -------------------------------------------------------------------------------- /html/images/logos/maven-feather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/images/logos/maven-feather.png -------------------------------------------------------------------------------- /html/images/newwindow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/images/newwindow.png -------------------------------------------------------------------------------- /html/testapidocs/ch/lambdaj/collection/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.collection (lambdaj 2.4-SNAPSHOT Test API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.collection

13 |
14 |

Interfaces

15 | 19 |

Classes

20 | 31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /html/testapidocs/ch/lambdaj/demo/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.demo (lambdaj 2.4-SNAPSHOT Test API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.demo

13 |
14 |

Classes

15 | 27 |
28 | 29 | 30 | -------------------------------------------------------------------------------- /html/testapidocs/ch/lambdaj/function/aggregate/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.function.aggregate (lambdaj 2.4-SNAPSHOT Test API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.function.aggregate

13 |
14 |

Interfaces

15 | 18 |

Classes

19 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /html/testapidocs/ch/lambdaj/function/argument/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.function.argument (lambdaj 2.4-SNAPSHOT Test API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.function.argument

13 |
14 |

Interfaces

15 | 19 |

Classes

20 | 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /html/testapidocs/ch/lambdaj/function/closure/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.function.closure (lambdaj 2.4-SNAPSHOT Test API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.function.closure

13 |
14 |

Classes

15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /html/testapidocs/ch/lambdaj/function/matcher/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.function.matcher (lambdaj 2.4-SNAPSHOT Test API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.function.matcher

13 |
14 |

Classes

15 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /html/testapidocs/ch/lambdaj/group/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.group (lambdaj 2.4-SNAPSHOT Test API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.group

13 |
14 |

Classes

15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /html/testapidocs/ch/lambdaj/mock/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.mock (lambdaj 2.4-SNAPSHOT Test API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.mock

13 |
14 |

Interfaces

15 | 19 |

Classes

20 | 29 |

Enums

30 | 33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /html/testapidocs/ch/lambdaj/proxy/nodefconstructor/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.proxy.nodefconstructor (lambdaj 2.4-SNAPSHOT Test API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.proxy.nodefconstructor

13 |
14 |

Classes

15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /html/testapidocs/ch/lambdaj/proxy/nodefconstructor/problem/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.proxy.nodefconstructor.problem (lambdaj 2.4-SNAPSHOT Test API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.proxy.nodefconstructor.problem

13 |
14 |

Classes

15 | 20 |
21 | 22 | 23 | -------------------------------------------------------------------------------- /html/testapidocs/ch/lambdaj/util/iterator/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ch.lambdaj.util.iterator (lambdaj 2.4-SNAPSHOT Test API) 8 | 9 | 10 | 11 | 12 |

ch.lambdaj.util.iterator

13 |
14 |

Classes

15 | 18 |
19 | 20 | 21 | -------------------------------------------------------------------------------- /html/testapidocs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | lambdaj 2.4-SNAPSHOT Test API 8 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | <noscript> 28 | <div>JavaScript is disabled on your browser.</div> 29 | </noscript> 30 | <h2>Frame Alert</h2> 31 | <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p> 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /html/testapidocs/overview-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Overview List (lambdaj 2.4-SNAPSHOT Test API) 8 | 9 | 10 | 11 | 12 |
All Classes
13 |
14 |

Packages

15 | 29 |
30 |

 

31 | 32 | 33 | -------------------------------------------------------------------------------- /html/testapidocs/package-list: -------------------------------------------------------------------------------- 1 | ch.lambdaj 2 | ch.lambdaj.collection 3 | ch.lambdaj.demo 4 | ch.lambdaj.function.aggregate 5 | ch.lambdaj.function.argument 6 | ch.lambdaj.function.closure 7 | ch.lambdaj.function.matcher 8 | ch.lambdaj.group 9 | ch.lambdaj.mock 10 | ch.lambdaj.proxy.nodefconstructor 11 | ch.lambdaj.proxy.nodefconstructor.problem 12 | ch.lambdaj.util.iterator 13 | -------------------------------------------------------------------------------- /html/testapidocs/resources/background.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/testapidocs/resources/background.gif -------------------------------------------------------------------------------- /html/testapidocs/resources/tab.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/testapidocs/resources/tab.gif -------------------------------------------------------------------------------- /html/testapidocs/resources/titlebar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/testapidocs/resources/titlebar.gif -------------------------------------------------------------------------------- /html/testapidocs/resources/titlebar_end.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/html/testapidocs/resources/titlebar_end.gif -------------------------------------------------------------------------------- /src/main/Main.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/collection/LambdaSet.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.collection; 6 | 7 | import org.hamcrest.*; 8 | 9 | import java.io.*; 10 | import java.util.*; 11 | 12 | /** 13 | * A Set that extends the Set interface with the fluent interface methods provided by lambdaj 14 | * @author Gianfranco Tognana 15 | * @author Mario Fusco 16 | */ 17 | public class LambdaSet extends LambdaCollection implements Set, Cloneable, Serializable { 18 | 19 | LambdaSet(Set inner) { 20 | super(inner); 21 | } 22 | 23 | /** 24 | * {@inheritDoc} 25 | */ 26 | public LambdaSet retain(Matcher matcher) { 27 | doRetain(matcher); 28 | return this; 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | */ 34 | public LambdaSet remove(Matcher matcher) { 35 | doRemove(matcher); 36 | return this; 37 | } 38 | 39 | /** 40 | * {@inheritDoc} 41 | */ 42 | @Override 43 | public LambdaSet clone() { 44 | return clone(new HashSet()); 45 | } 46 | 47 | /** 48 | * Returns a shallow copy of this LambdaSet instance. (The elements themselves are not copied.) 49 | * @param emptyList The empty set to be used as wrapped set of this LambdaSet if the current one is not Cloneable 50 | * @return A clone of this LambdaSet instance 51 | */ 52 | public LambdaSet clone(Set emptyList) { 53 | return new LambdaSet((Set)innerClone(emptyList)); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/Aggregator.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | import java.util.*; 8 | 9 | /** 10 | * Defines an aggregation operation, i.e. how to aggregate the items of a collection. 11 | * @author Mario Fusco 12 | */ 13 | public interface Aggregator { 14 | 15 | /** 16 | * Defines how this operation aggregates a list of objects 17 | * @param iterator The objects to be aggregated 18 | * @return The aggregation of the objects 19 | */ 20 | T aggregate(Iterator iterator); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/Avg.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.function.aggregate; 2 | 3 | import java.math.*; 4 | import java.util.*; 5 | 6 | /** 7 | * An aggregator calculating numbers' average 8 | * @author Mario Fusco 9 | */ 10 | public class Avg extends Sum { 11 | 12 | int itemsCounter = 0; 13 | 14 | /** 15 | * {@inheritDoc} 16 | */ 17 | public Number aggregate(Iterator iterator) { 18 | return divide(super.aggregate(iterator), itemsCounter); 19 | } 20 | 21 | /** 22 | * {@inheritDoc} 23 | */ 24 | public Number aggregate(Number first, Number second) { 25 | itemsCounter++; 26 | return super.aggregate(first, second); 27 | } 28 | 29 | private Number divide(Number total, int count) { 30 | if (count < 2) return total; 31 | if (total instanceof Integer) return total.intValue() / count; 32 | if (total instanceof Long) return total.longValue() / count; 33 | if (total instanceof Float) return total.floatValue() / count; 34 | if (total instanceof Double) return total.doubleValue() / count; 35 | if (total instanceof BigInteger) return ((BigInteger)total).divide(BigInteger.valueOf(count)); 36 | if (total instanceof BigDecimal) return ((BigDecimal)total).divide(new BigDecimal(count)); 37 | throw new RuntimeException("Unknown number type"); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/Chooser.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | /** 8 | * An abstract class that define the behaviour af an Aggregator which aggregates two items 9 | * of a collection just by choosing one of them. 10 | * @author Mario Fusco 11 | */ 12 | public abstract class Chooser extends PairAggregator { 13 | 14 | /** 15 | * Chooses on the two items returning the non-null one if one of them is null or by applying 16 | * the strategy defined by the {@link Chooser#choose(Object, Object)} method if both of them are not null 17 | * @param first The first item on which make the choice 18 | * @param second The second item on which make the choice 19 | * @return The choosen item 20 | */ 21 | public T aggregate(T first, T second) { 22 | if (first == null) return second; 23 | if (second == null) return first; 24 | return choose(first, second); 25 | } 26 | 27 | /** 28 | * Chooses between two non null items. 29 | * @param first The first item on which make the choice 30 | * @param second The second item on which make the choice 31 | * @return The choosen item 32 | */ 33 | protected abstract T choose(T first, T second); 34 | 35 | /** 36 | * Just returns null which is the idempotent item for a choosing aggreagation 37 | * @return null 38 | */ 39 | public T emptyItem() { 40 | return null; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/ChooserOnArgument.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | import static ch.lambdaj.function.argument.ArgumentsFactory.*; 8 | import ch.lambdaj.function.argument.*; 9 | 10 | /** 11 | * An Aggregator that chooses between two item based on the value of an argument operation invoked on them. 12 | * @author Mario Fusco 13 | */ 14 | public abstract class ChooserOnArgument extends Chooser { 15 | 16 | private final Argument argument; 17 | 18 | /** 19 | * Creates a chooser that uses the value extracted by applying the given argument 20 | * @param argument The argument used to extract values from the items between which to choose 21 | */ 22 | public ChooserOnArgument(A argument) { 23 | this.argument = actualArgument(argument); 24 | } 25 | 26 | /** 27 | * Chooses between two non null items based on the value of one of their argument 28 | * @param first The first item on which make the choice 29 | * @param second The second item on which make the choice 30 | * @return The choosen item 31 | */ 32 | @Override 33 | protected T choose(T first, T second) { 34 | A firstArgument = argument.evaluate(first); 35 | if (firstArgument == null) return second; 36 | A secondArgument = argument.evaluate(second); 37 | if (secondArgument == null) return first; 38 | return chooseOnArgument(first, firstArgument, second, secondArgument); 39 | } 40 | 41 | /** 42 | * Chooses between two non null items based on the value of one of their argument 43 | * @param first The first item on which make the choice 44 | * @param firstArgument The value of the argument evaluated on the first item 45 | * @param second The second item on which make the choice 46 | * @param secondArgument The value of the argument evaluated on the second item 47 | * @return The choosen item 48 | */ 49 | protected abstract T chooseOnArgument(T first, A firstArgument, T second, A secondArgument); 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/Concat.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | import java.util.*; 8 | 9 | /** 10 | * An Aggregator that concats String or more generally the String representation of a given Object 11 | * @author Mario Fusco 12 | */ 13 | public class Concat implements Aggregator { 14 | 15 | private final String separator; 16 | 17 | /** 18 | * Creates an aggregator that concats Strings using the default separator \", \" 19 | */ 20 | public Concat() { 21 | this(", "); 22 | } 23 | 24 | /** 25 | * Creates an aggregator that concats Strings using the given separator 26 | * @param separator The string used to separate two concatenated Strings 27 | */ 28 | public Concat(String separator) { 29 | this.separator = separator; 30 | } 31 | 32 | /** 33 | * Aggregates two object by concatenating their String representation separating them with the choosen separator. 34 | * It has been implemented a custom implementation for this method instead of using the one provided 35 | * by the PairAggregator for performance reason, in order to levarege the StringBuilder features. 36 | * @param iterator The objects of which the String representation should be concatenated 37 | * @return A String resulting of the objects Stringification separated by the given argument 38 | */ 39 | public Object aggregate(Iterator iterator) { 40 | if (iterator == null) return ""; 41 | StringBuilder sb = new StringBuilder(); 42 | while (iterator.hasNext()) { 43 | Object item = iterator.next(); 44 | if (item == null) continue; 45 | String itemAsString = item.toString(); 46 | if (!itemAsString.trim().equals("")) { 47 | sb.append(itemAsString); 48 | break; 49 | } 50 | } 51 | while (iterator.hasNext()) { 52 | Object item = iterator.next(); 53 | if (item == null) continue; 54 | String itemAsString = item.toString(); 55 | if (!itemAsString.trim().equals("")) sb.append(separator).append(itemAsString); 56 | } 57 | return sb.toString(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/InitializedPairAggregator.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | /** 8 | * A PairAggregator that is initialized to the value of its idempotent item. 9 | * @author Mario Fusco 10 | */ 11 | public abstract class InitializedPairAggregator extends PairAggregator { 12 | 13 | private final T firstItem; 14 | 15 | /** 16 | * Creates a PairAggregator that is initialized to the value of its idempotent item 17 | * @param firstItem the value with which this PairAggregator is initialized 18 | */ 19 | public InitializedPairAggregator(T firstItem) { 20 | this.firstItem = firstItem; 21 | } 22 | 23 | /** 24 | * {@inheritDoc} 25 | */ 26 | public final T emptyItem() { 27 | return firstItem; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/Max.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | /** 8 | * A chooser of the maximum value between two comparable 9 | * @author Mario Fusco 10 | */ 11 | public class Max extends Chooser> { 12 | 13 | /** 14 | * Chooses the maximum value between two Comparable 15 | * @param first The first item between which find the maximum 16 | * @param second The second item between which find the maximum 17 | * @return The biggest between the two items 18 | */ 19 | @SuppressWarnings("unchecked") 20 | @Override 21 | protected Comparable choose(Comparable first, Comparable second) { 22 | return first.compareTo((T) second) > 0 ? first : second; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/MaxOnArgument.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | /** 8 | * A chooser of the item having the maximum value on an argument operation invoked on it. 9 | * @author Mario Fusco 10 | */ 11 | public class MaxOnArgument extends ChooserOnArgument { 12 | 13 | /** 14 | * Creates a chooser that uses the value extracted by applying the given argument 15 | * @param argument The argument used to extract values from the items between which to find the maximum 16 | */ 17 | public MaxOnArgument(A argument) { 18 | super(argument); 19 | } 20 | 21 | /** 22 | * Finds the item having the maximum value on the given argument 23 | * @param first The first item on which make the choice 24 | * @param firstArgument The value of the argument evaluated on the first item 25 | * @param second The second item on which make the choice 26 | * @param secondArgument The value of the argument evaluated on the second item 27 | * @return The item having the maximum value on the given argument 28 | */ 29 | @SuppressWarnings("unchecked") 30 | @Override 31 | protected T chooseOnArgument(T first, A firstArgument, T second, A secondArgument) { 32 | return ((Comparable)firstArgument).compareTo(secondArgument) > 0 ? first : second; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/Min.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | /** 8 | * A chooser of the minimum value between two comparable 9 | * @author Mario Fusco 10 | */ 11 | public class Min extends Chooser> { 12 | 13 | /** 14 | * Chooses the minimum value between two Comparable 15 | * @param first The first item between which find the minimum 16 | * @param second The second item between which find the minimum 17 | * @return The smallest between the two items 18 | */ 19 | @SuppressWarnings("unchecked") 20 | @Override 21 | protected Comparable choose(Comparable first, Comparable second) { 22 | return first.compareTo((T) second) < 0 ? first : second; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/MinOnArgument.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | /** 8 | * A chooser of the item having the minimum value on an argument operation invoked on it. 9 | * @author Mario Fusco 10 | */ 11 | public class MinOnArgument extends ChooserOnArgument { 12 | 13 | /** 14 | * Creates a chooser that uses the value extracted by applying the given argument 15 | * @param argument The argument used to extract values from the items between which to find the minimum 16 | */ 17 | public MinOnArgument(A argument) { 18 | super(argument); 19 | } 20 | 21 | /** 22 | * Finds the item having the minimum value on the given argument 23 | * @param first The first item on which make the choice 24 | * @param firstArgument The value of the argument evaluated on the first item 25 | * @param second The second item on which make the choice 26 | * @param secondArgument The value of the argument evaluated on the second item 27 | * @return The item having the minimum value on the given argument 28 | */ 29 | @SuppressWarnings("unchecked") 30 | @Override 31 | protected T chooseOnArgument(T first, A firstArgument, T second, A secondArgument) { 32 | return ((Comparable)firstArgument).compareTo(secondArgument) < 0 ? first : second; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/PairAggregator.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | import java.util.*; 8 | 9 | /** 10 | * An aggregator that uses the definition of how to aggregate a pair of items 11 | * and of the empty (idempotent respect to this aggregation) item. 12 | * @author Mario Fusco 13 | */ 14 | public abstract class PairAggregator implements Aggregator { 15 | 16 | /** 17 | * Aggregates the objects in the given iterable by aggregating the i-th item with the aggreagation of all the 18 | * former i-1 items. The first item is aggregated with what as been defined as the empty (idempotent) item. 19 | * @param iterator The objects to be aggregated 20 | * @return The aggregation of the objects 21 | */ 22 | public T aggregate(Iterator iterator) { 23 | T result = emptyItem(); 24 | if (iterator != null) while (iterator.hasNext()) { result = aggregate(result, iterator.next()); } 25 | return result; 26 | } 27 | 28 | /** 29 | * Returns the idempotent item for this aggregation operation 30 | */ 31 | protected abstract T emptyItem(); 32 | 33 | /** 34 | * Defines how this operation aggregates 2 different objects 35 | * @param first The first object to be aggregated 36 | * @param second The second object to be aggregated 37 | * @return The aggregation of first and second objects 38 | */ 39 | protected abstract T aggregate(T first, T second); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/ProxyAggregator.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | import java.lang.reflect.*; 8 | import java.math.*; 9 | import java.util.*; 10 | 11 | import ch.lambdaj.util.iterator.*; 12 | import ch.lambdaj.proxy.*; 13 | 14 | /** 15 | * Proxies a list of objects in order to seamlessly aggregate their value by exposing the API of a single object. 16 | * @author Mario Fusco 17 | */ 18 | public class ProxyAggregator extends ProxyIterator { 19 | 20 | private final Aggregator aggregator; 21 | 22 | protected ProxyAggregator(ResettableIterator proxiedIterator, Aggregator aggregator) { 23 | super(proxiedIterator); 24 | this.aggregator = aggregator; 25 | } 26 | 27 | @Override 28 | public Object invoke(Object obj, Method method, Object[] args) { 29 | if(enabled) return normalizeResult(method.getReturnType(), aggregator.aggregate((Iterator)iterateOnValues(method, args))); 30 | return null; 31 | } 32 | 33 | private Object normalizeResult(Class expectedResultType, Object result) { 34 | if (result == null) return normalizeNullResult(expectedResultType, result); 35 | if (expectedResultType.isInstance(result)) return result; 36 | if (expectedResultType == BigInteger.class) return new BigInteger(result.toString()); 37 | if (expectedResultType == BigDecimal.class) return new BigDecimal(result.toString()); 38 | return result; 39 | } 40 | 41 | private Object normalizeNullResult(Class expectedResultType, Object result) { 42 | if (expectedResultType == BigInteger.class) return BigInteger.ZERO; 43 | if (expectedResultType == BigDecimal.class) return BigDecimal.ZERO; 44 | return result; 45 | } 46 | 47 | @SuppressWarnings("unchecked") 48 | public static T createProxyAggregator(ResettableIterator proxiedIterator, Aggregator aggregator, Class clazz) { 49 | return (T)ProxyUtil.createIterableProxy(new ProxyAggregator(proxiedIterator, aggregator), clazz); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/SumDouble.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | /** 8 | * An aggregator that sums doubles 9 | * @author Mario Fusco 10 | */ 11 | public class SumDouble extends InitializedPairAggregator { 12 | 13 | /** 14 | * Creates an aggregator that sums doubles 15 | * @param firstItem The first double to be summed 16 | */ 17 | public SumDouble(Double firstItem) { 18 | super(firstItem); 19 | } 20 | 21 | /** 22 | * Aggregates two doubles by summing them 23 | * @param first The first double to be summed 24 | * @param second The second double to be summed 25 | * @return The sum of the two doubles 26 | */ 27 | public Double aggregate(Double first, Double second) { 28 | return first + second; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/SumInteger.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | /** 8 | * An aggregator that sums ints 9 | * @author Mario Fusco 10 | */ 11 | public class SumInteger extends InitializedPairAggregator { 12 | 13 | /** 14 | * Creates an aggregator that sums ints 15 | * @param firstItem The first int to be summed 16 | */ 17 | public SumInteger(Integer firstItem) { 18 | super(firstItem); 19 | } 20 | 21 | /** 22 | * Aggregates two ints by summing them 23 | * @param first The first int to be summed 24 | * @param second The second int to be summed 25 | * @return The sum of the two ints 26 | */ 27 | public Integer aggregate(Integer first, Integer second) { 28 | return first + second; 29 | } 30 | } -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/aggregate/SumLong.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | /** 8 | * An aggregator that sums longs 9 | * @author Mario Fusco 10 | */ 11 | public class SumLong extends InitializedPairAggregator { 12 | 13 | /** 14 | * Creates an aggregator that sums longs 15 | * @param firstItem The first long to be summed 16 | */ 17 | public SumLong(Long firstItem) { 18 | super(firstItem); 19 | } 20 | 21 | /** 22 | * Aggregates two longs by summing them 23 | * @param first The first long to be summed 24 | * @param second The second long to be summed 25 | * @return The sum of the two longs 26 | */ 27 | public Long aggregate(Long first, Long second) { 28 | return first + second; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/argument/ArgumentConversionException.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.argument; 6 | 7 | /** 8 | * This exception is thrown when is not possible to convert a placeholder object in an Argument 9 | * @author Mario Fusco 10 | */ 11 | public class ArgumentConversionException extends RuntimeException { 12 | 13 | ArgumentConversionException(String message) { 14 | super(message); 15 | } 16 | 17 | ArgumentConversionException(String message, Throwable cause) { 18 | super(message, cause); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/argument/FinalClassArgumentCreator.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.argument; 6 | 7 | /** 8 | * A factpry for creating arguments placeholder for final classes 9 | * @author Mario Fusco 10 | */ 11 | public interface FinalClassArgumentCreator { 12 | 13 | /** 14 | * Create a placeholder for an argument of the final class T using the given seed. 15 | * @param seed The seed to generate the unique placeholder 16 | * @return A placeholder for an argument of class T 17 | */ 18 | T createArgumentPlaceHolder(int seed); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/argument/Invoker.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.argument; 6 | 7 | public interface Invoker { 8 | Object invokeOn(Object object); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/argument/ProxyArgument.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.argument; 6 | 7 | import static ch.lambdaj.function.argument.ArgumentsFactory.*; 8 | 9 | import java.lang.ref.*; 10 | import java.lang.reflect.*; 11 | 12 | import ch.lambdaj.proxy.*; 13 | 14 | /** 15 | * @author Mario Fusco 16 | */ 17 | class ProxyArgument extends InvocationInterceptor { 18 | 19 | private final Class proxiedClass; 20 | 21 | private final WeakReference invocationSequence; 22 | 23 | ProxyArgument(Class proxiedClass, InvocationSequence invocationSequence) { 24 | this.proxiedClass = proxiedClass; 25 | this.invocationSequence = new WeakReference(invocationSequence); 26 | } 27 | 28 | /** 29 | * {@inheritDoc} 30 | */ 31 | public Object invoke(Object proxy, Method method, Object[] args) { 32 | if (method.getName().equals("hashCode")) return invocationSequence.hashCode(); 33 | if (method.getName().equals("equals")) return invocationSequence.equals(args[0]); 34 | 35 | // Adds this invocation to the current invocation sequence and creates a new proxy propagating the invocation sequence 36 | return createArgument(method.getReturnType(), new InvocationSequence(invocationSequence.get(), new Invocation(proxiedClass, method, args))); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/closure/Closure0.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.closure; 6 | 7 | /** 8 | * A closure with no free variables 9 | * @author Mario Fusco 10 | */ 11 | public class Closure0 extends AbstractClosure { 12 | 13 | /** 14 | * Invoke this closure 15 | * @return The result of the closure invocation 16 | */ 17 | public Object apply() { 18 | return closeOne(); 19 | } 20 | 21 | /** 22 | * Defines the method invoked by this closure. 23 | * @param closedObject The object on which the closure has to be invoked. It can be a fixed object or a Class. 24 | * In this last case, if the method is not static, it is treated as it was an 25 | * unbound argument defined through the {@link ch.lambdaj.Lambda#var(Class)} method 26 | * @param methodName The name of the method invoked by this closure or {@link AbstractClosure#CONSTRUCTOR} 27 | * if you want to call a constructor 28 | * @param args The arguments used to invoke this closure. They can be a mixed of fixed value and 29 | * unbound one defined through the {@link ch.lambdaj.Lambda#var(Class)} method 30 | * @return The closure itself 31 | */ 32 | @Override 33 | public Closure0 of(Object closedObject, String methodName, Object ... args) { 34 | return (Closure0)super.of(closedObject, methodName, args); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/closure/ClosureResult.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.closure; 6 | 7 | /** 8 | * The result returned by a closure defined through the delayed syntax 9 | * @author Mario Fusco 10 | */ 11 | public interface ClosureResult { 12 | 13 | /** 14 | * The result returned by the delayed closure invocation 15 | * @return The closure invocation result 16 | */ 17 | T get(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/closure/Invokable.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.closure; 6 | 7 | /** 8 | * @author Mario Fusco 9 | */ 10 | interface Invokable { 11 | 12 | /** 13 | * Inkvokes the given object with this Invokable using the given set of arguments 14 | * @param obj The object on which this Invokable will be invoked 15 | * @param args The argument used to invoke this Invokable 16 | * @return The result of the invocation 17 | */ 18 | Object invoke(Object obj, Object... args); 19 | 20 | /** 21 | * Returns true if this invokable is static 22 | * @return True if this invokable is static false otherwise 23 | */ 24 | boolean isStatic(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/closure/InvokableConstructor.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.closure; 6 | 7 | import java.lang.reflect.*; 8 | 9 | /** 10 | * An Invokable that invokes a constructor 11 | * @author Mario Fusco 12 | */ 13 | class InvokableConstructor implements Invokable { 14 | 15 | private final Constructor constructor; 16 | 17 | /** 18 | * Creates A Invokable that invokes a constructor 19 | * @param constructor the constrctor to be invoked 20 | */ 21 | public InvokableConstructor(Constructor constructor) { 22 | this.constructor = constructor; 23 | } 24 | 25 | /** 26 | * {@inheritDoc} 27 | */ 28 | public Object invoke(Object obj, Object... args) { 29 | try { 30 | return constructor.newInstance(args); 31 | } catch (Exception e) { 32 | throw new WrongClosureInvocationException("Error invoking constroctor for " + constructor.getDeclaringClass(), e); 33 | } 34 | } 35 | 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | public boolean isStatic() { 40 | return true; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/closure/InvokableMethod.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.closure; 6 | 7 | import java.lang.reflect.*; 8 | 9 | /** 10 | * An Invokable that invokes a method 11 | * @author Mario Fusco 12 | */ 13 | class InvokableMethod implements Invokable { 14 | 15 | private final Method method; 16 | 17 | /** 18 | * Creates A Invokable that invokes a method 19 | * @param method the method to be invoked 20 | */ 21 | public InvokableMethod(Method method) { 22 | this.method = method; 23 | } 24 | 25 | /** 26 | * {@inheritDoc} 27 | */ 28 | public Object invoke(Object obj, Object... args) { 29 | try { 30 | return method.invoke(obj, args); 31 | } catch (Exception e) { 32 | throw new WrongClosureInvocationException("Error invoking " + method + " on " + obj, e); 33 | } 34 | } 35 | 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | public boolean isStatic() { 40 | return Modifier.isStatic(method.getModifiers()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/closure/ProxyClosure.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.closure; 6 | 7 | import static ch.lambdaj.function.closure.ClosuresFactory.*; 8 | 9 | import java.lang.reflect.*; 10 | 11 | import ch.lambdaj.proxy.*; 12 | 13 | /** 14 | * @author Mario Fusco 15 | */ 16 | class ProxyClosure extends InvocationInterceptor { 17 | 18 | private boolean registered = false; 19 | 20 | private final AbstractClosure closure; 21 | 22 | ProxyClosure(AbstractClosure closure) { 23 | this.closure = closure; 24 | } 25 | 26 | public Object invoke(Object proxy, Method method, Object[] args) throws InvocationTargetException, IllegalAccessException { 27 | if (registered) return method.invoke(proxy, args); 28 | registered = true; 29 | closure.bindInvocation(method, args); 30 | 31 | DelayedClosure.call(); 32 | 33 | Class returnType = method.getReturnType(); 34 | if (returnType == Void.TYPE) { 35 | closure.closeUnhandledInvocations(); 36 | return null; 37 | } 38 | return createProxyClosure(closure, returnType); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/closure/WrongClosureInvocationException.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.closure; 6 | 7 | /** 8 | * This Exception is thrown when a closure gets invoked with a wrong number or type of variables 9 | * @author Mario Fusco 10 | */ 11 | public class WrongClosureInvocationException extends RuntimeException { 12 | 13 | private static final long serialVersionUID = 1L; 14 | 15 | WrongClosureInvocationException(String message) { 16 | super(message); 17 | } 18 | 19 | WrongClosureInvocationException(String message, Throwable cause) { 20 | super(message, cause); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/compare/PropertyComparator.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.compare; 6 | 7 | import java.util.Comparator; 8 | import java.io.*; 9 | 10 | import static ch.lambdaj.function.compare.ComparatorUtil.nullSafeCompare; 11 | import static ch.lambdaj.util.IntrospectionUtil.getPropertyValue; 12 | 13 | /** 14 | * Compares two objects by comparing the values of one of their property. 15 | * @author Mario Fusco 16 | */ 17 | public class PropertyComparator implements Comparator, Serializable { 18 | 19 | private final String propertyName; 20 | 21 | /** 22 | * Creates a comparator that compares two objects by comparing the values of one of their property 23 | * @param propertyName The name of the property to be compared 24 | */ 25 | public PropertyComparator(String propertyName) { 26 | this.propertyName = propertyName; 27 | } 28 | 29 | /** 30 | * {@inheritDoc} 31 | */ 32 | @SuppressWarnings("unchecked") 33 | public int compare(T o1, T o2) { 34 | return nullSafeCompare(getPropertyValue(o1, propertyName), getPropertyValue(o2, propertyName)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/convert/AliasedArgumentConverter.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.convert; 6 | 7 | import static ch.lambdaj.function.argument.ArgumentsFactory.*; 8 | import ch.lambdaj.function.argument.*; 9 | 10 | import java.util.*; 11 | 12 | /** 13 | * Converts an object in a key/value pair where the value is the one returned by the evaluation of the given argument on the object itself. 14 | * @author Mario Fusco 15 | */ 16 | public class AliasedArgumentConverter implements Converter> { 17 | 18 | private final String alias; 19 | private final Argument argument; 20 | 21 | /** 22 | * Creates a converter that projects the value of the argument of an object using as alias 23 | * the argument property name as defined by {@link Argument#getInkvokedPropertyName()} 24 | * @param argument An argument defined using the {@link ch.lambdaj.Lambda#on(Class)} method 25 | */ 26 | public AliasedArgumentConverter(T argument) { 27 | this.argument = actualArgument(argument); 28 | alias = this.argument.getInkvokedPropertyName(); 29 | } 30 | 31 | /** 32 | * Creates a converter that projects the value of the argument of an object using as the given alias 33 | * @param alias The key on which the argument value is paired 34 | * @param argument An argument defined using the {@link ch.lambdaj.Lambda#on(Class)} method 35 | */ 36 | public AliasedArgumentConverter(String alias, T argument) { 37 | this.argument = actualArgument(argument); 38 | this.alias = alias; 39 | } 40 | 41 | /** 42 | * {@inheritDoc} 43 | */ 44 | public Map.Entry convert(final F from) { 45 | return new Map.Entry() { 46 | public String getKey() { return alias; } 47 | public T getValue() { return argument.evaluate(from); } 48 | public T setValue(T value) { throw new UnsupportedOperationException(); } 49 | }; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/convert/ArgumentConverter.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.convert; 6 | 7 | import static ch.lambdaj.function.argument.ArgumentsFactory.*; 8 | import ch.lambdaj.function.argument.*; 9 | 10 | /** 11 | * Converts an object in the value returned by the evaluation of the given argument on it. 12 | * @author Mario Fusco 13 | */ 14 | public class ArgumentConverter implements Converter { 15 | 16 | private final Argument argument; 17 | 18 | /** 19 | * Creates an ArgumentConverter 20 | */ 21 | public ArgumentConverter(Argument argument) { 22 | this.argument = argument; 23 | } 24 | 25 | /** 26 | * Creates an ArgumentConverter 27 | */ 28 | public ArgumentConverter(T argument) { 29 | this(actualArgument(argument)); 30 | } 31 | 32 | /** 33 | * {@inheritDoc} 34 | */ 35 | public T convert(F from) { 36 | return argument.evaluate(from); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/convert/ConstructorArgumentConverter.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.convert; 6 | 7 | import ch.lambdaj.util.*; 8 | 9 | import java.lang.reflect.*; 10 | import java.util.*; 11 | 12 | /** 13 | * Creates an object of the given Class by invoking its constructor passing to it the values taken 14 | * from the object to be converted using the given arguments. 15 | * @author Mario Fusco 16 | */ 17 | public class ConstructorArgumentConverter implements Converter { 18 | 19 | private Constructor constructor; 20 | 21 | private final List> argumentConverters = new LinkedList>(); 22 | 23 | public ConstructorArgumentConverter(Class clazz, Object... arguments) { 24 | for (Constructor c : clazz.getConstructors()) { 25 | if (isCompatible(c, arguments)) { 26 | this.constructor = (Constructor)c; 27 | break; 28 | } 29 | } 30 | 31 | if (constructor == null) 32 | throw new IntrospectionException("Unable to find a constructor of " + clazz.getName() + " compatible with the given arguments"); 33 | 34 | if (arguments != null) 35 | for (Object argument : arguments) { argumentConverters.add(new ArgumentConverter(argument)); } 36 | } 37 | 38 | private boolean isCompatible(Constructor constructor, Object... arguments) { 39 | try { 40 | constructor.newInstance(arguments); 41 | return true; 42 | } catch (Exception e) { 43 | return false; 44 | } 45 | } 46 | 47 | /** 48 | * {@inheritDoc} 49 | */ 50 | public T convert(F from) { 51 | Object[] initArgs = new Object[argumentConverters.size()]; 52 | int i = 0; 53 | for (ArgumentConverter argumentConverter : argumentConverters) { 54 | initArgs[i++] = argumentConverter.convert(from); 55 | } 56 | try { 57 | return constructor.newInstance(initArgs); 58 | } catch (Exception e) { 59 | throw new IntrospectionException("Unable to create an object of class " + constructor.getDeclaringClass().getName(), e); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/convert/Converter.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.convert; 6 | 7 | /** 8 | * Specifies how to convert from an object of type F to an object of type T 9 | * @author Mario Fusco 10 | */ 11 | public interface Converter { 12 | 13 | /** 14 | * Converts from an object of type F to an object of type T 15 | * @param from The object to be converted 16 | * @return The conversion result 17 | */ 18 | T convert(F from); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/convert/ConverterIterator.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.convert; 6 | 7 | import java.util.*; 8 | 9 | /** 10 | * An Iterator that converts its items using the given Converter while iterating on them. 11 | * @author Mario Fusco 12 | */ 13 | public class ConverterIterator implements Iterator { 14 | 15 | private final Converter converter; 16 | private final Iterator iterator; 17 | 18 | /** 19 | * Creates a ConverterIterator 20 | */ 21 | public ConverterIterator(Converter converter, Iterator iterator) { 22 | this.converter = converter; 23 | this.iterator = iterator; 24 | } 25 | 26 | /** 27 | * {@inheritDoc} 28 | */ 29 | public boolean hasNext() { 30 | return iterator.hasNext(); 31 | } 32 | 33 | /** 34 | * {@inheritDoc} 35 | */ 36 | public T next() { 37 | return converter.convert(iterator.next()); 38 | } 39 | 40 | /** 41 | * {@inheritDoc} 42 | */ 43 | public void remove() { 44 | iterator.remove(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/convert/DefaultStringConverter.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.convert; 6 | 7 | /** 8 | * Converts an object in its String representation or an empty String for a null object. 9 | * @author Mario Fusco 10 | */ 11 | public class DefaultStringConverter implements StringConverter { 12 | 13 | /** 14 | * {@inheritDoc} 15 | */ 16 | public String convert(Object from) { 17 | return from == null ? "" : from.toString(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/convert/ProjectConverter.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.convert; 6 | 7 | import java.util.*; 8 | 9 | /** 10 | * Convert an Object in map of key/value pairs by projecting them using the given projectors 11 | * @author Mario Fusco 12 | */ 13 | public class ProjectConverter implements Converter> { 14 | 15 | private final Converter>[] projectors; 16 | 17 | /** 18 | * Creates a Converter that converts an Object in map of key/value pairs by projecting them using the given projectors 19 | * @param projectors The converters used to convert the object properties in a key/value pair 20 | */ 21 | public ProjectConverter(Converter>... projectors) { 22 | this.projectors = projectors; 23 | } 24 | 25 | /** 26 | * {@inheritDoc} 27 | */ 28 | public Map convert(F from) { 29 | Map map = new HashMap(); 30 | for (Converter> projector : projectors) { 31 | Map.Entry entry = projector.convert(from); 32 | map.put(entry.getKey(), entry.getValue()); 33 | } 34 | return map; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/convert/PropertyExtractor.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.convert; 6 | 7 | import ch.lambdaj.util.IntrospectionUtil; 8 | 9 | 10 | /** 11 | * Converts an Object in the value it has on the name property. 12 | * @author Mario Fusco 13 | */ 14 | public class PropertyExtractor implements Converter { 15 | 16 | private final String propertyName; 17 | 18 | /** 19 | * Creates a PropertyExtractor 20 | */ 21 | public PropertyExtractor(String propertyName) { 22 | this.propertyName = propertyName; 23 | } 24 | 25 | /** 26 | * {@inheritDoc} 27 | */ 28 | @SuppressWarnings("unchecked") 29 | public T convert(F from) { 30 | return (T)IntrospectionUtil.getPropertyValue(from, propertyName); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/convert/StringConverter.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.convert; 6 | 7 | 8 | /** 9 | * Specifies how to convert from an object of type F to a String 10 | * @author Mario Fusco 11 | */ 12 | public interface StringConverter extends Converter { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/convert/StringLengthConverter.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.convert; 6 | 7 | 8 | /** 9 | * Converts a String in an Integer equal to its length. 10 | * @author Mario Fusco 11 | */ 12 | public class StringLengthConverter extends PropertyExtractor { 13 | 14 | /** 15 | * Creates a StringLengthConverter 16 | */ 17 | public StringLengthConverter() { 18 | super("length"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/convert/StringPropertyExtractor.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.convert; 6 | 7 | 8 | /** 9 | * Converts an Object in the String representation of the value it has on the name property. 10 | * @author Mario Fusco 11 | */ 12 | public class StringPropertyExtractor extends PropertyExtractor implements StringConverter { 13 | 14 | public StringPropertyExtractor(String propertyName) { 15 | super(propertyName); 16 | } 17 | 18 | /** 19 | * {@inheritDoc} 20 | */ 21 | @Override 22 | public String convert(T from) { 23 | Object converted = super.convert(from); 24 | return converted == null ? "" : converted.toString(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/matcher/AndMatcher.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.matcher; 6 | 7 | import org.hamcrest.*; 8 | 9 | /** 10 | * A matcher that logically combines a set of matchers returning true if all of them satisfy its own condition. 11 | * @author Mario Fusco 12 | */ 13 | public final class AndMatcher extends LambdaJMatcher { 14 | 15 | private final Matcher[] matchers; 16 | 17 | private AndMatcher(Matcher... matchers) { 18 | this.matchers = matchers; 19 | } 20 | 21 | /** 22 | * {@inheritDoc} 23 | */ 24 | public boolean matches(Object item) { 25 | for (Matcher matcher : matchers) { if (!matcher.matches(item)) return false; } 26 | return true; 27 | } 28 | 29 | /** 30 | * Creates an and matcher combining all the passed matchers 31 | * @param matchers The matchers to be put in and 32 | * @return A matcher that return true if all the matchers return true 33 | */ 34 | @Factory 35 | public static AndMatcher and(Matcher... matchers) { 36 | return new AndMatcher(matchers); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/matcher/HasNestedPropertyWithValue.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.matcher; 6 | 7 | import static ch.lambdaj.util.IntrospectionUtil.*; 8 | 9 | import org.hamcrest.*; 10 | 11 | /** 12 | * A matcher that returns true if the value af the named property matches the given matcher. 13 | * @author Mario Fusco 14 | */ 15 | public class HasNestedPropertyWithValue extends LambdaJMatcher { 16 | 17 | private final String propertyName; 18 | private final Matcher value; 19 | 20 | /** 21 | * Creates a matcher that returns true if the value af the named property matches the given matcher 22 | * @param propertyName The name of the property 23 | * @param value The value to be mathced 24 | */ 25 | public HasNestedPropertyWithValue(String propertyName, Matcher value) { 26 | this.propertyName = propertyName; 27 | this.value = value; 28 | } 29 | 30 | /** 31 | * {@inheritDoc} 32 | */ 33 | public boolean matches(Object item) { 34 | try { 35 | return value.matches(getPropertyValue(item, propertyName)); 36 | } catch (Exception e) { 37 | return false; 38 | } 39 | } 40 | 41 | /** 42 | * {@inheritDoc} 43 | */ 44 | @Override 45 | public void describeTo(Description description) { 46 | description.appendText("hasProperty("); 47 | description.appendValue(propertyName); 48 | description.appendText(", "); 49 | description.appendDescriptionOf(value); 50 | description.appendText(")"); 51 | } 52 | 53 | /** 54 | * Creates a matcher that returns true if the value af the named property matches the given matcher 55 | * @param propertyName The name of the property 56 | * @param value The value to be mathced 57 | * @return A matcher that returns true if the value af the named property matches the given matcher 58 | */ 59 | @Factory 60 | public static Matcher hasNestedProperty(String propertyName, Matcher value) { 61 | return new HasNestedPropertyWithValue(propertyName, value); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/matcher/LambdaJMatcher.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.matcher; 6 | 7 | import org.hamcrest.*; 8 | 9 | 10 | /** 11 | * A Matcher that extends the Hamcrest BaseMatcher by adding two fluent interface style methods that 12 | * allow to logically combine two matchers. 13 | * @author Mario Fusco 14 | */ 15 | public abstract class LambdaJMatcher extends BaseMatcher { 16 | 17 | /** 18 | * Creates an and matcher combining this matcher and the given one 19 | * @param matcher The matcher to be put in and with this one 20 | * @return A matcher that return true if this matcher and the passed one return true 21 | */ 22 | @SuppressWarnings("unchecked") 23 | public final LambdaJMatcher and(Matcher matcher) { 24 | return AndMatcher.and(this, matcher); 25 | } 26 | 27 | /** 28 | * Creates an or matcher combining this matcher and the given one 29 | * @param matcher The matcher to be put in or with this one 30 | * @return A matcher that return true if this matcher or the passed one return true 31 | */ 32 | @SuppressWarnings("unchecked") 33 | public final LambdaJMatcher or(Matcher matcher) { 34 | return OrMatcher.or(this, matcher); 35 | } 36 | 37 | /** 38 | * {@inheritDoc} 39 | */ 40 | public void describeTo(Description description) { } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/matcher/OrMatcher.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.matcher; 6 | 7 | import org.hamcrest.*; 8 | 9 | /** 10 | * A matcher that logically combines a set of matchers returning true if at least one of them satisfies its own condition. 11 | * @author Mario Fusco 12 | */ 13 | public final class OrMatcher extends LambdaJMatcher { 14 | 15 | private final Matcher[] matchers; 16 | 17 | private OrMatcher(Matcher... matchers) { 18 | this.matchers = matchers; 19 | } 20 | 21 | /** 22 | * {@inheritDoc} 23 | */ 24 | public boolean matches(Object item) { 25 | for (Matcher matcher : matchers) { if (matcher.matches(item)) return true; } 26 | return false; 27 | } 28 | 29 | /** 30 | * Creates an or matcher combining all the passed matchers 31 | * @param matchers The matchers to be put in or 32 | * @return A matcher that return true if at least one of the matchers return true 33 | */ 34 | @Factory 35 | public static OrMatcher or(Matcher... matchers) { 36 | return new OrMatcher(matchers); 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/function/matcher/Predicate.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.function.matcher; 2 | 3 | import org.hamcrest.*; 4 | 5 | /** 6 | * A type safe LambdaJMatcher. 7 | * @author Mario Fusco 8 | */ 9 | public abstract class Predicate extends LambdaJMatcher { 10 | 11 | private final InnerMatcher innerMatcher = new InnerMatcher(); 12 | 13 | /** 14 | * Evaluates this Predicate on the given item 15 | * @param item The object against which this Predicate is evaluated 16 | * @return true if item matches, otherwise false 17 | */ 18 | public abstract boolean apply(T item); 19 | 20 | /** 21 | * {@inheritDoc} 22 | */ 23 | public final boolean matches(Object item) { 24 | return innerMatcher.matches(item); 25 | } 26 | 27 | private class InnerMatcher extends TypeSafeMatcher { 28 | /** 29 | * {@inheritDoc} 30 | */ 31 | @Override 32 | public boolean matchesSafely(T item) { 33 | return apply(item); 34 | } 35 | 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | public void describeTo(Description description) {} 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/group/ArgumentGroupCondition.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.group; 6 | 7 | import static ch.lambdaj.function.argument.ArgumentsFactory.*; 8 | import ch.lambdaj.function.argument.*; 9 | 10 | /** 11 | * A GroupCondition that allows to group items based on the value they have on a given argument 12 | * @author Mario Fusco 13 | */ 14 | public class ArgumentGroupCondition extends GroupCondition> { 15 | 16 | private final Argument groupBy; 17 | private final String groupName; 18 | 19 | ArgumentGroupCondition(T argument) { 20 | groupBy = actualArgument(argument); 21 | groupName = groupBy.getInkvokedPropertyName(); 22 | } 23 | 24 | /** 25 | * {@inheritDoc} 26 | */ 27 | protected String getGroupName() { 28 | return groupName; 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | */ 34 | protected Object getGroupValue(Object item) { 35 | return groupBy.evaluate(item); 36 | } 37 | 38 | /** 39 | * Sets an alias for the groups created using this condition 40 | * @param alias The alias to be set 41 | * @return The GroupCondition itself in order to allow a fluent interface 42 | */ 43 | @Override 44 | public ArgumentGroupCondition as(String alias) { 45 | return (ArgumentGroupCondition)super.as(alias); 46 | } 47 | 48 | /** 49 | * Adds the value of the given argument in the group's header 50 | * @param argument The argument 51 | * @return The ArgumentGroupCondition itself 52 | */ 53 | public ArgumentGroupCondition head(Object argument) { 54 | Argument actualArgument = actualArgument(argument); 55 | additionalProperties.put(actualArgument.getInkvokedPropertyName(), actualArgument); 56 | return this; 57 | } 58 | 59 | /** 60 | * Adds the value of the given argument in the group's header with the given alias 61 | * @param argument The argument 62 | * @param alias The alias 63 | * @return The ArgumentGroupCondition itself 64 | */ 65 | public ArgumentGroupCondition head(Object argument, String alias) { 66 | additionalProperties.put(alias, actualArgument(argument)); 67 | return this; 68 | } 69 | 70 | /** 71 | * {@inheritDoc} 72 | */ 73 | protected String getAdditionalPropertyValue(String name, Object item) { 74 | return asNotNullString(additionalProperties.get(name).evaluate(item)); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/group/GroupComparator.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.group; 6 | 7 | import static ch.lambdaj.function.argument.ArgumentsFactory.*; 8 | import static ch.lambdaj.function.compare.ComparatorUtil.nullSafeCompare; 9 | 10 | import ch.lambdaj.function.argument.*; 11 | 12 | import java.util.*; 13 | import java.io.*; 14 | 15 | /** 16 | * A comparator that allows to sort group based on the value assumed on the given argument 17 | * by the object that is the key for a group itself 18 | * @author Mario Fusco 19 | */ 20 | class GroupComparator> implements Comparator>, Serializable { 21 | 22 | private final Argument argument; 23 | 24 | /** 25 | * Creates a comparator that compares two groups by comparing the values assumed on the given argument 26 | * @param argument The argument identifying the property to be compared 27 | */ 28 | public GroupComparator(A argument) { 29 | this(actualArgument(argument)); 30 | } 31 | 32 | /** 33 | * Creates a comparator that compares two groups by comparing the values assumed on the given argument 34 | * @param argument The argument identifying the property to be compared 35 | */ 36 | public GroupComparator(Argument argument) { 37 | this.argument = argument; 38 | } 39 | 40 | /** 41 | * {@inheritDoc} 42 | */ 43 | public int compare(GroupItem group1, GroupItem group2) { 44 | return nullSafeCompare(argument.evaluate(group1.getGroupKey()), argument.evaluate(group2.getGroupKey())); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/group/GroupConditions.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.group; 6 | 7 | import java.util.*; 8 | 9 | /** 10 | * Defines a list of GroupConditions. 11 | * Extending it makes easy to create a simple DSL that creates GroupConditions for some specific objects of your domain. 12 | * @author Mario Fusco 13 | */ 14 | public class GroupConditions extends LinkedList { 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | /** 19 | * Adds a GroupCondition the groups on the property with the given name 20 | * @param by The name of property to be used in the new GroupCondition 21 | */ 22 | public void by(String by) { 23 | add(new StringGroupCondition(by)); 24 | } 25 | 26 | /** 27 | * Sets an alias for the groups created using this condition 28 | * @param alias The alias to be set 29 | */ 30 | public void as(String alias) { 31 | getLast().as(alias); 32 | } 33 | 34 | /** 35 | * Adds the value of the property with the given name as a header of the groups produced by applying this Condition 36 | * @param property The name of the property 37 | */ 38 | public void head(String property) { 39 | getLast().head(property); 40 | } 41 | 42 | /** 43 | * Adds the value of the property with the given name as a header with the given alias of the groups produced by applying this Condition 44 | * @param property The name of the property 45 | * @param alias The alias used as name in the group header 46 | */ 47 | public void head(String property, String alias) { 48 | getLast().head(alias, property); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/group/GroupItem.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.group; 6 | 7 | import java.util.*; 8 | 9 | /** 10 | * @author Mario Fusco 11 | */ 12 | public class GroupItem extends TreeMap implements Iterable { 13 | 14 | private static final long serialVersionUID = 1L; 15 | 16 | private static final String CHILDREN_NODE = "children"; 17 | private String childrenNodeName = CHILDREN_NODE; 18 | 19 | private boolean leaf = true; 20 | 21 | private final Object groupKey; 22 | 23 | GroupItem() { 24 | groupKey = null; 25 | } 26 | 27 | GroupItem(Object groupKey, String childrenNodeName) { 28 | this.groupKey = groupKey; 29 | if (childrenNodeName != null) this.childrenNodeName = childrenNodeName; 30 | } 31 | 32 | Object getGroupKey() { 33 | return groupKey; 34 | } 35 | 36 | private String getChildrenNodeName() { 37 | return childrenNodeName; 38 | } 39 | 40 | @SuppressWarnings("unchecked") 41 | private List getChildren() { 42 | List children = (List) get(getChildrenNodeName()); 43 | if (children == null) { 44 | children = new LinkedList(); 45 | put(getChildrenNodeName(), children); 46 | } 47 | return children; 48 | } 49 | 50 | /** 51 | * Convert this GroupItem in the corresponding Group 52 | * @return The Group wrapping this GroupItem 53 | */ 54 | @SuppressWarnings("unchecked") 55 | public Group asGroup() { 56 | return leaf ? new LeafGroup(this, getChildrenNodeName()) : (Group)get(getChildrenNodeName()); 57 | } 58 | 59 | /** 60 | * {@inheritDoc} 61 | */ 62 | public Iterator iterator() { 63 | return asList().iterator(); 64 | } 65 | 66 | List asList() { 67 | if (leaf) return getChildren(); 68 | List leafs = new LinkedList(); 69 | for (T item : asGroup().findAll()) { leafs.add(item); } 70 | return leafs; 71 | } 72 | 73 | void addChild(T child) { 74 | if (!leaf) throw new IllegalStateException("cannot add a child to a non-leaf group"); 75 | getChildren().add(child); 76 | } 77 | 78 | void setChildren(GroupImpl children) { 79 | leaf = false; 80 | children.setKey(getGroupKey()); 81 | put(getChildrenNodeName(), children); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/group/StringGroupCondition.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.group; 6 | 7 | import static ch.lambdaj.util.IntrospectionUtil.getPropertyValue; 8 | 9 | 10 | /** 11 | * A GroupCondition that groups items based on the values they have on the named JavaBean property 12 | * @author Mario Fusco 13 | */ 14 | public class StringGroupCondition extends GroupCondition { 15 | 16 | private final String groupBy; 17 | 18 | /** 19 | * Creates a GroupCondition that groups items based on the values they have on the given JavaBean property 20 | * @param groupBy The name of the property on which the items have to be grouped 21 | */ 22 | public StringGroupCondition(String groupBy) { 23 | this(groupBy, null); 24 | } 25 | 26 | /** 27 | * Creates a GroupCondition that groups items based on the values they have on the given JavaBean property 28 | * @param groupBy The name of the property on which the items have to be grouped 29 | * @param alias The alias used for the groups created using this condition 30 | */ 31 | public StringGroupCondition(String groupBy, String alias) { 32 | this.groupBy = groupBy; 33 | as(alias); 34 | } 35 | 36 | protected String getGroupName() { 37 | return groupBy; 38 | } 39 | 40 | protected Object getGroupValue(Object item) { 41 | return getPropertyValue(item, groupBy); 42 | } 43 | 44 | /** 45 | * Adds the value of the property with the given name as a header of the groups produced by applying this Condition 46 | * @param name The name of the property 47 | * @return This StringGroupCondition 48 | */ 49 | public StringGroupCondition head(String name) { 50 | return head(name, name); 51 | } 52 | 53 | /** 54 | * Adds the value of the property with the given name as a header with the given alias of the groups produced by applying this Condition 55 | * @param name The name of the property 56 | * @param alias The alias used as name in the group header 57 | * @return This StringGroupCondition 58 | */ 59 | public StringGroupCondition head(String name, String alias) { 60 | additionalProperties.put(name, alias); 61 | return this; 62 | } 63 | 64 | protected String getAdditionalPropertyValue(String name, Object item) { 65 | return asNotNullString(getPropertyValue(item, additionalProperties.get(name))); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/proxy/InvocationInterceptor.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.proxy; 6 | 7 | import java.lang.reflect.*; 8 | 9 | import net.sf.cglib.proxy.*; 10 | 11 | /** 12 | * An intercptor that seamlessly manages invocations on both a native Java proxy and a cglib one. 13 | * @author Mario Fusco 14 | */ 15 | public abstract class InvocationInterceptor implements MethodInterceptor, java.lang.reflect.InvocationHandler { 16 | 17 | /** 18 | * {@inheritDoc} 19 | */ 20 | public final Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { 21 | return invoke(proxy, method, args); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/proxy/UnproxableClassException.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.proxy; 6 | 7 | /** 8 | * This invocation is thrown while trying to proxy an object of an unproxeable (final) class. 9 | * @author Mario Fusco 10 | */ 11 | public class UnproxableClassException extends RuntimeException { 12 | 13 | private static final long serialVersionUID = 1L; 14 | 15 | UnproxableClassException(Class clazz) { 16 | super("Unable to proxy the final class " + clazz.getName()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/util/IntrospectionException.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.util; 6 | 7 | /** 8 | * This Exception is thrown when something in the introspection process goes wrong. 9 | * @author Mario Fusco 10 | */ 11 | public class IntrospectionException extends RuntimeException { 12 | 13 | /** 14 | * Constructs a new IntrospectionException with the specified cause. 15 | * @param cause The root cause of this Exception 16 | */ 17 | public IntrospectionException(Throwable cause) { 18 | super(cause); 19 | } 20 | 21 | /** 22 | * Constructs a new IntrospectionException with the specified message. 23 | * @param message The message of this Exception 24 | */ 25 | public IntrospectionException(String message) { 26 | super(message); 27 | } 28 | 29 | /** 30 | * Constructs a new IntrospectionException with the specified cause and message. 31 | * @param cause The root cause of this Exception 32 | * @param message The message of this Exception 33 | */ 34 | public IntrospectionException(String message, Throwable cause) { 35 | super(message, cause); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/util/NotUniqueItemException.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.util; 6 | 7 | /** 8 | * This Exception is thrown when a selected item is not unique as expected 9 | * @author Mario Fusco 10 | */ 11 | public class NotUniqueItemException extends RuntimeException { 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/util/iterator/MatchingIterator.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.util.iterator; 6 | 7 | import org.hamcrest.*; 8 | 9 | import java.util.*; 10 | 11 | /** 12 | * Wraps an iterator filtering its items with the given hamcrest Matcher 13 | * @author Mario Fusco 14 | * @author Andrea Polci 15 | */ 16 | public class MatchingIterator implements Iterator { 17 | 18 | private final Iterator iterator; 19 | private final Matcher matcher; 20 | 21 | private T nextElement; 22 | private boolean nextAvailable = false; 23 | 24 | /** 25 | * Creates an Iterator that wraps another iterator filtering its items with the given hamcrest Matcher 26 | * @param iterator The iterator to be wrapped and filtered 27 | * @param matcher The matcher used to filter the wrapped iterator 28 | */ 29 | public MatchingIterator(Iterator iterator, Matcher matcher) { 30 | this.iterator = iterator; 31 | this.matcher = matcher; 32 | } 33 | 34 | private void searchNext() { 35 | nextElement = null; 36 | while (iterator.hasNext() && nextElement == null) { 37 | T n = iterator.next(); 38 | if (matcher.matches(n)) nextElement = n; 39 | } 40 | nextAvailable = true; 41 | } 42 | 43 | /** 44 | * {@inheritDoc} 45 | */ 46 | public boolean hasNext() { 47 | if (!nextAvailable) searchNext(); 48 | return nextElement != null; 49 | } 50 | 51 | /** 52 | * {@inheritDoc} 53 | */ 54 | public T next() { 55 | if (!hasNext()) throw new NoSuchElementException(); 56 | T n = nextElement; 57 | nextAvailable = false; 58 | return n; 59 | } 60 | 61 | /** 62 | * {@inheritDoc} 63 | */ 64 | public void remove() { 65 | throw new UnsupportedOperationException(); 66 | } 67 | } -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/util/iterator/ResettableIterator.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.util.iterator; 6 | 7 | import java.util.*; 8 | 9 | /** 10 | * An Iterator that can reset its cursor to its initial position 11 | * @author Mario Fusco 12 | */ 13 | public abstract class ResettableIterator implements Iterator { 14 | 15 | /** 16 | * Resets the cursor of this Iterator to its initial position 17 | */ 18 | public abstract void reset(); 19 | 20 | /** 21 | * {@inheritDoc} 22 | */ 23 | public void remove() { 24 | throw new UnsupportedOperationException(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/util/iterator/ResettableIteratorOnArray.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.util.iterator; 6 | 7 | import java.util.*; 8 | 9 | /** 10 | * A ResettabkeIterator that iterates over a wrapped arrey 11 | * @author Mario Fusco 12 | */ 13 | public class ResettableIteratorOnArray extends ResettableIterator { 14 | 15 | private final T[] array; 16 | private int counter = 0; 17 | 18 | /** 19 | * Creates a ResettableIterator that wraps the given array 20 | * @param array The array to be wrapped 21 | */ 22 | public ResettableIteratorOnArray(T[] array) { 23 | this.array = array; 24 | } 25 | 26 | /** 27 | * {@inheritDoc} 28 | */ 29 | public boolean hasNext() { 30 | return counter < array.length; 31 | } 32 | 33 | /** 34 | * {@inheritDoc} 35 | */ 36 | public T next() { 37 | if (!hasNext()) throw new NoSuchElementException(); 38 | return array[counter++]; 39 | } 40 | 41 | /** 42 | * {@inheritDoc} 43 | */ 44 | public void reset() { 45 | counter = 0; 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/util/iterator/ResettableIteratorOnIterable.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.util.iterator; 6 | 7 | import java.util.*; 8 | 9 | /** 10 | * A ResettabkeIterator that iterates over a wrapped Iterable 11 | * @author Mario Fusco 12 | */ 13 | public class ResettableIteratorOnIterable extends ResettableIterator { 14 | 15 | private final Iterable iterable; 16 | 17 | private Iterator iterator; 18 | 19 | /** 20 | * Creates a ResettableIterator that wraps the given Iterable 21 | * @param iterable The Iterable to be wrapped 22 | */ 23 | public ResettableIteratorOnIterable(Iterable iterable) { 24 | this.iterable = iterable; 25 | reset(); 26 | } 27 | 28 | /** 29 | * {@inheritDoc} 30 | */ 31 | public final void reset() { 32 | iterator = iterable.iterator(); 33 | } 34 | 35 | /** 36 | * {@inheritDoc} 37 | */ 38 | public boolean hasNext() { 39 | return iterator.hasNext(); 40 | } 41 | 42 | /** 43 | * {@inheritDoc} 44 | */ 45 | public T next() { 46 | return iterator.next(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/ch/lambdaj/util/iterator/ResettableIteratorOnIterator.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.util.iterator; 6 | 7 | import java.util.*; 8 | 9 | /** 10 | * A ResettabkeIterator that iterates over a wrapped Iterator 11 | * @author Mario Fusco 12 | */ 13 | public class ResettableIteratorOnIterator extends ResettableIterator { 14 | 15 | private final Iterator iterator; 16 | 17 | private final List innerIterable = new LinkedList(); 18 | private Iterator innerIterator; 19 | 20 | private final List cache = new LinkedList(); 21 | 22 | /** 23 | * Creates a ResettableIterator that wraps the given Iterator 24 | * @param iterator The Iterator to be wrapped 25 | */ 26 | public ResettableIteratorOnIterator(Iterator iterator) { 27 | this.iterator = iterator; 28 | innerIterator = innerIterable.iterator(); 29 | } 30 | 31 | /** 32 | * {@inheritDoc} 33 | */ 34 | public void reset() { 35 | innerIterable.addAll(cache); 36 | cache.clear(); 37 | innerIterator = innerIterable.iterator(); 38 | } 39 | 40 | /** 41 | * {@inheritDoc} 42 | */ 43 | public boolean hasNext() { 44 | return iterator.hasNext() || innerIterator.hasNext(); 45 | } 46 | 47 | /** 48 | * {@inheritDoc} 49 | */ 50 | public T next() { 51 | if (innerIterator.hasNext()) return innerIterator.next(); 52 | if (iterator.hasNext()) { 53 | T next = iterator.next(); 54 | cache.add(next); 55 | return next; 56 | } 57 | throw new NoSuchElementException(); 58 | } 59 | } -------------------------------------------------------------------------------- /src/test/Test.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/ArgumentCornerCaseTest.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj; 6 | 7 | import org.junit.*; 8 | 9 | import java.util.*; 10 | 11 | import static ch.lambdaj.Lambda.*; 12 | import static java.util.Arrays.asList; 13 | import static junit.framework.Assert.assertEquals; 14 | 15 | /** 16 | * @author Mario Fusco 17 | */ 18 | public class ArgumentCornerCaseTest { 19 | 20 | @Test 21 | public void testSimpleGet() { 22 | Date expectedMin = new Date(System.currentTimeMillis()-500); 23 | 24 | Intervals intervals1 = new Intervals(new Interval(new Date(), new Date())); 25 | Intervals intervals2 = new Intervals(new Interval(expectedMin, new Date(System.currentTimeMillis()-400))); 26 | Intervals intervals3 = new Intervals(new Interval(new Date(System.currentTimeMillis()-300), new Date(System.currentTimeMillis()-200))); 27 | 28 | List intervals = asList(intervals1, intervals2, intervals3); 29 | Date dateArgument = on(Intervals.class).get().getStart(); 30 | Date min = min(intervals, on(Intervals.class).get().getStart()); 31 | 32 | assertEquals("get.start", argument(dateArgument).getInkvokedPropertyName()); 33 | assertEquals(expectedMin, min); 34 | } 35 | 36 | public static class Intervals { 37 | List intervals; 38 | 39 | public Intervals(Interval interval) { 40 | intervals = new ArrayList(); 41 | intervals.add(interval); 42 | } 43 | 44 | public Intervals(List intervals) { 45 | this.intervals = intervals; 46 | } 47 | 48 | public List getIntervals() { return intervals; } 49 | 50 | public Interval get() { return intervals.get(0); } 51 | } 52 | 53 | public static class Interval { 54 | private Date start; 55 | private Date end; 56 | 57 | public Interval(Date start, Date end) { 58 | this.start = start; 59 | this.end = end; 60 | } 61 | 62 | public Date getStart() { return start; } 63 | public Date getEnd() { return end; } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/Assert.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj; 6 | 7 | import static org.junit.Assert.*; 8 | 9 | import org.hamcrest.*; 10 | 11 | import ch.lambdaj.function.aggregate.*; 12 | 13 | import static java.util.Arrays.asList; 14 | 15 | /** @author Luca Marrocco */ 16 | @SuppressWarnings("unchecked") 17 | public class Assert { 18 | public static final void assertThatSum(Number op1, T op2, Matcher matcher) { 19 | Sum summer = new Sum(); 20 | T result = (T) summer.aggregate(op1, op2); 21 | assertThat(result, matcher); 22 | } 23 | 24 | public static final void assertThatMin(T op1, T op2, Matcher matcher) { 25 | Min minFinder = new Min(); 26 | T result = (T) minFinder.aggregate(op1, op2); 27 | assertThat(result, matcher); 28 | } 29 | 30 | public static final void assertThatMax(T op1, T op2, Matcher matcher) { 31 | Max maxFinder = new Max(); 32 | T result = (T) maxFinder.aggregate(op1, op2); 33 | assertThat(result, matcher); 34 | } 35 | 36 | public static final void assertThatConcat(String op1, String op2, Matcher matcher) { 37 | Concat concatenator = new Concat(); 38 | String result = (String) concatenator.aggregate(asList(op1, op2).iterator()); 39 | assertThat(result, matcher); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/ClosureVoidMethodInvocationTest.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj; 2 | 3 | import static ch.lambdaj.Lambda.*; 4 | import static java.util.Arrays.asList; 5 | import static junit.framework.Assert.*; 6 | 7 | import ch.lambdaj.function.closure.*; 8 | import org.junit.*; 9 | 10 | import java.util.*; 11 | 12 | public class ClosureVoidMethodInvocationTest { 13 | 14 | class Person { 15 | private final String name; 16 | 17 | Person(String name) { 18 | this.name = name; 19 | } 20 | 21 | void talk() { 22 | talked.add(name); 23 | } 24 | 25 | Person getFriend(String friendName) { 26 | return new Person(friendName); 27 | } 28 | } 29 | 30 | /* capture fact that method was called */ 31 | private List talked = new ArrayList(); 32 | 33 | @Test 34 | public void testShallReplayChainedMethodCalls() { 35 | Closure closure = closure(); { 36 | of(new Person("Bob")).getFriend("Sue").talk(); 37 | } 38 | 39 | assertTrue(talked.isEmpty()); 40 | closure.apply(); 41 | assertEquals(asList("Sue"), talked); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/ConstructorBugTest.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj; 2 | 3 | import org.junit.*; 4 | 5 | import static ch.lambdaj.Lambda.sumFrom; 6 | import static java.util.Arrays.asList; 7 | import static junit.framework.Assert.assertEquals; 8 | 9 | /** 10 | * @author Mario Fusco 11 | */ 12 | public class ConstructorBugTest { 13 | static class NonInterfaceItem { 14 | 15 | private int value; 16 | 17 | public NonInterfaceItem() { 18 | setValue(10); // Set default value 19 | } 20 | 21 | public int getValue() { 22 | return value; 23 | } 24 | 25 | public void setValue(int value) { 26 | this.value = value; 27 | } 28 | } 29 | 30 | @Test 31 | public void callsFromConstructorAreForwarded() { 32 | NonInterfaceItem item1 = new NonInterfaceItem(); 33 | item1.setValue(20); 34 | 35 | NonInterfaceItem item2 = new NonInterfaceItem(); 36 | item2.setValue(50); 37 | 38 | assertEquals(70, sumFrom(asList(item1, item2)).getValue()); // Fail - is 20 39 | assertEquals(20, item1.getValue()); // Fail - is 10 40 | assertEquals(50, item2.getValue()); // Fail - is 10 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/DelayedClosureTest.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj; 2 | 3 | import static org.junit.Assert.*; 4 | import static ch.lambdaj.Lambda.*; 5 | 6 | import ch.lambdaj.function.closure.*; 7 | import java.io.*; 8 | import java.util.*; 9 | import org.junit.*; 10 | 11 | /** 12 | * @author Guillaume Bort 13 | * @author Mario Fusco 14 | */ 15 | public class DelayedClosureTest { 16 | 17 | PrintWriter out; 18 | 19 | @Test 20 | public void testWithTransaction() { 21 | StringWriter sw = new StringWriter(); 22 | out = new PrintWriter(sw); 23 | 24 | withTransaction(); { 25 | of(this).sayHello(); 26 | } 27 | 28 | System.out.println(sw.toString()); 29 | assertEquals("BEGIN -- Hello ! -- COMMIT", sw.toString()); 30 | } 31 | 32 | @Test 33 | public void testMyGrep() throws Exception { 34 | List strings = new ArrayList(); 35 | strings.add("Yop"); 36 | strings.add("Ho"); 37 | strings.add("Kiki"); 38 | strings.add("Bi"); 39 | 40 | ClosureResult> result = grep(strings); { 41 | of(this).moreThan2Chars(var(String.class)); 42 | } 43 | 44 | List resultList = result.get(); 45 | assertEquals(2, resultList.size()); 46 | assertEquals("Yop", resultList.get(0)); 47 | assertEquals("Kiki", resultList.get(1)); 48 | } 49 | 50 | // ~~~~ 51 | 52 | public boolean moreThan2Chars(String c) { 53 | return c.length() > 2; 54 | } 55 | 56 | public void sayHello() { 57 | out.print("Hello !"); 58 | } 59 | 60 | public void withTransaction() { 61 | delayedClosure(new DelayedClosure() { 62 | 63 | @Override 64 | public Void doWithClosure(Closure closure) { 65 | out.print("BEGIN -- "); 66 | closure.apply(); 67 | out.print(" -- COMMIT"); 68 | return null; 69 | } 70 | }); 71 | } 72 | 73 | public ClosureResult> grep(final List objects) { 74 | return delayedClosure(new DelayedClosure>() { 75 | 76 | @Override 77 | public List doWithClosure(Closure closure) { 78 | List filtered = new ArrayList(); 79 | for (T object : objects) { 80 | if ((Boolean) closure.apply(object)) { 81 | filtered.add(object); 82 | } 83 | } 84 | return filtered; 85 | } 86 | }); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/PrimitiveReferenceTest.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import org.junit.Before; 10 | import org.junit.Test; 11 | import static ch.lambdaj.Lambda.*; 12 | import static org.hamcrest.Matchers.*; 13 | import static org.junit.Assert.*; 14 | 15 | /** 16 | * @author f.baronti 17 | */ 18 | public class PrimitiveReferenceTest { 19 | 20 | private static final int ITEMS = 100; 21 | private static final int TESTS = 1000; 22 | 23 | private List items; 24 | 25 | @Before 26 | public void setUp() { 27 | items = new ArrayList(); 28 | for (int i = 0; i < ITEMS; i++) { 29 | items.add(new TestItem()); 30 | } 31 | } 32 | 33 | @Test 34 | public void testStressParameterlessFilter() throws InterruptedException { 35 | for (int t = 0; t < TESTS; t++) { 36 | List l = filter(having(on(TestItem.class).isValue(), equalTo(true)), items); 37 | assertEquals("Mismatch at iteration " + t + " on parameterless filter,", ITEMS, l.size()); 38 | } 39 | } 40 | 41 | @Test 42 | public void testStressPrimitiveParameterFilter() throws InterruptedException { 43 | for (int t = 0; t < TESTS; t++) { 44 | List l = filter(having(on(TestItem.class).isValue(0), equalTo(true)), items); 45 | assertEquals("Mismatch at iteration " + t + " on parameter filter,", ITEMS, l.size()); 46 | } 47 | } 48 | 49 | @Test 50 | public void testStressParameterFilter() throws InterruptedException { 51 | for (int t = 0; t < TESTS; t++) { 52 | List l = filter(having(on(TestItem.class).isValue(0L), equalTo(true)), items); 53 | assertEquals("Mismatch at iteration " + t + " on parameter filter,", ITEMS, l.size()); 54 | } 55 | } 56 | 57 | public static class TestItem { 58 | public boolean isValue(Long i) { 59 | return true; 60 | } 61 | 62 | public boolean isValue(int i) { 63 | return true; 64 | } 65 | 66 | public boolean isValue() { 67 | return true; 68 | } 69 | } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/Strings.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj; 6 | 7 | import net.sf.json.*; 8 | import net.sf.json.util.*; 9 | 10 | 11 | /** 12 | * @author Mario Fusco 13 | * @author Luca Marrocco 14 | */ 15 | public class Strings { 16 | 17 | public static String json(Object object) { 18 | if (JSONUtils.isArray(object)) return JSONArray.fromObject(object).toString(); 19 | if (JSONUtils.isObject(object)) return JSONObject.fromObject(object).toString(); 20 | return object.toString(); 21 | } 22 | 23 | public static String removeApos(String json) { 24 | return json.replaceAll("\"", ""); 25 | } 26 | 27 | public static String removeString(String json, String match) { 28 | return json.replace(match, ""); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/demo/Car.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.demo; 2 | 3 | public class Car { 4 | 5 | private String brand; 6 | private String model; 7 | private int year; 8 | private double originalValue; 9 | 10 | protected Car() { } 11 | 12 | public Car(String brand, String model, int year, double originalValue) { 13 | this.brand = brand; 14 | this.model = model; 15 | this.year = year; 16 | this.originalValue = originalValue; 17 | } 18 | 19 | public String getBrand() { 20 | return brand; 21 | } 22 | 23 | public String getBrand2() { 24 | return brand; 25 | } 26 | 27 | public String getModel() { 28 | return model; 29 | } 30 | 31 | public int getYear() { 32 | return year; 33 | } 34 | 35 | public double getOriginalValue() { 36 | return originalValue; 37 | } 38 | 39 | public String getName() { 40 | return getBrand() + " " + getModel(); 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return getName(); 46 | } 47 | 48 | @Override 49 | public int hashCode() { 50 | return getName().hashCode(); 51 | } 52 | 53 | @Override 54 | public boolean equals(Object obj) { 55 | if (!Car.class.isInstance(obj)) return false; 56 | return getName().equals(((Car)obj).getName()); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/demo/Person.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.demo; 2 | 3 | import static ch.lambdaj.demo.Util.*; 4 | 5 | import java.util.*; 6 | 7 | public class Person { 8 | 9 | private String firstName; 10 | private String lastName; 11 | private boolean male; 12 | private Date birthday; 13 | 14 | protected Person() { } 15 | 16 | public Person(String firstName, String lastName, boolean male, String birthday) { 17 | this.firstName = firstName; 18 | this.lastName = lastName; 19 | this.male = male; 20 | this.birthday = formatDate(birthday); 21 | } 22 | 23 | public String getFirstName() { 24 | return firstName; 25 | } 26 | 27 | public String getLastName() { 28 | return lastName; 29 | } 30 | 31 | public String getFullName() { 32 | return getFirstName() + " " + getLastName(); 33 | } 34 | 35 | public boolean isMale() { 36 | return male; 37 | } 38 | 39 | public int getAge() { 40 | return getCurrentYear() - getBirthYear(); 41 | } 42 | 43 | public int getBirthYear() { 44 | return getYear(birthday); 45 | } 46 | 47 | public Date getBirthday() { 48 | return birthday; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return getFullName(); 54 | } 55 | 56 | @Override 57 | public boolean equals(Object obj) { 58 | return Person.class.isInstance(obj) && getFullName().equals(((Person)obj).getFullName()); 59 | } 60 | 61 | @Override 62 | public int hashCode() { 63 | return getFullName().hashCode(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/demo/Sale.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.demo; 2 | 3 | 4 | public class Sale { 5 | 6 | private Person seller; 7 | private Person buyer; 8 | private Car car; 9 | private double cost; 10 | 11 | protected Sale() { } 12 | 13 | public Sale(Person seller, Person buyer, Car car, double cost) { 14 | this.seller = seller; 15 | this.buyer = buyer; 16 | this.car = car; 17 | this.cost = cost; 18 | } 19 | 20 | public Person getSeller() { 21 | return seller; 22 | } 23 | 24 | public Person getBuyer() { 25 | return buyer; 26 | } 27 | 28 | public Car getCar() { 29 | return car; 30 | } 31 | 32 | public double getCost() { 33 | return cost; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "Sale of " + car + " from " + seller + " to " + buyer + " for " + cost; 39 | } 40 | 41 | @Override 42 | public int hashCode() { 43 | return toString().hashCode(); 44 | } 45 | 46 | @Override 47 | public boolean equals(Object obj) { 48 | if (!Sale.class.isInstance(obj)) return false; 49 | return toString().equals(obj.toString()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/demo/Util.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.demo; 2 | 3 | import java.text.*; 4 | import java.util.*; 5 | 6 | public class Util { 7 | 8 | public static final DateFormat DEFAUALT_DATE_FORMAT = new SimpleDateFormat("dd/MM/yyyy"); 9 | 10 | public static Date formatDate(String date) { 11 | try { 12 | return DEFAUALT_DATE_FORMAT.parse(date); 13 | } catch (ParseException e) { 14 | e.printStackTrace(); 15 | } 16 | return null; 17 | } 18 | 19 | public static int getCurrentYear() { 20 | return getYear(new Date()); 21 | } 22 | 23 | public static int getYear(Date date) { 24 | Calendar calendar = new GregorianCalendar(); 25 | calendar.setTime(date); 26 | return calendar.get(Calendar.YEAR); 27 | } 28 | 29 | public static boolean listsAreEqual(List list1, List list2) { 30 | if (list1 == null && list2 == null) return true; 31 | if (list1 == null || list2 == null) return false; 32 | if (list1.size() != list2.size()) return false; 33 | for (int i = 0; i < list1.size(); i++) if (!list1.get(i).equals(list2.get(i))) return false; 34 | return true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/function/aggregate/AggregateTest.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.function.aggregate; 2 | 3 | import static ch.lambdaj.function.aggregate.Money.*; 4 | import static ch.lambdaj.Lambda.*; 5 | import static java.util.Arrays.*; 6 | import static org.junit.Assert.*; 7 | 8 | import java.util.*; 9 | 10 | import org.junit.*; 11 | 12 | public class AggregateTest { 13 | 14 | @Test 15 | public void testAggregateGrossPremium(){ 16 | Premium endorsementPremium1 = premiumOf("1,311,314,330.89 GBP"); 17 | Premium endorsementPremium2 = premiumOf("96,563,001.19 GBP"); 18 | Premium endorsementPremium3 = premiumOf("4,443,725.16 GBP"); 19 | 20 | List endorsementPremiums = asList(endorsementPremium1, endorsementPremium2, endorsementPremium3); 21 | 22 | Premium totalizer = aggregateFrom(endorsementPremiums, Premium.class, new MoneyAggregator()); 23 | 24 | assertEquals(money("1,412,321,057.24 GBP").getValue(), totalizer.getPremium().getValue(), 0.000001); 25 | } 26 | 27 | private Premium premiumOf(final String value) { 28 | return new Premium() { 29 | public Money getPremium() { 30 | return money(value); 31 | } 32 | }; 33 | } 34 | 35 | public interface Premium { 36 | Money getPremium(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/function/aggregate/ConcatTest.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | import static ch.lambdaj.Assert.*; 8 | import static org.hamcrest.Matchers.*; 9 | 10 | import org.junit.*; 11 | 12 | /** @author Luca Marrocco */ 13 | public class ConcatTest { 14 | 15 | @Test 16 | public void testConcatStrings() { 17 | assertThatConcat("", "", is(equalTo(""))); 18 | assertThatConcat("a", "a", is(equalTo("a, a"))); 19 | } 20 | 21 | @Test 22 | public void testConcatStringAndNumber() { 23 | assertThatConcat("a", "1", is(equalTo("a, 1"))); 24 | assertThatConcat("1", "a", is(equalTo("1, a"))); 25 | } 26 | 27 | @Test 28 | public void testConcatStringAndNull() { 29 | assertThatConcat("", null, is(equalTo(""))); 30 | assertThatConcat(null, "", is(equalTo(""))); 31 | } 32 | 33 | @Test 34 | public void testConcatNull() { 35 | assertThatConcat(null, null, is(equalTo(""))); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/function/aggregate/MaxTest.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | import static ch.lambdaj.Assert.*; 8 | import static org.hamcrest.Matchers.*; 9 | 10 | import org.junit.*; 11 | 12 | /** @author Luca Marrocco */ 13 | public class MaxTest { 14 | 15 | @Test 16 | public void testLesserFirst() { 17 | assertThatMax(1, 2, is(equalTo(2))); 18 | assertThatMax(2, 3, is(equalTo(3))); 19 | assertThatMax(3, 4, is(equalTo(4))); 20 | assertThatMax(1, null, is(equalTo(1))); 21 | } 22 | 23 | @Test 24 | public void testGreaterFirst() { 25 | assertThatMax(4, 3, is(equalTo(4))); 26 | assertThatMax(3, 2, is(equalTo(3))); 27 | assertThatMax(2, 1, is(equalTo(2))); 28 | assertThatMax(null, 1, is(equalTo(1))); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/function/aggregate/Measure.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.function.aggregate; 2 | 3 | /** 4 | * @author Luca Marrocco 5 | */ 6 | public class Measure { 7 | 8 | protected String name; 9 | 10 | protected String unit; 11 | 12 | protected double value; 13 | 14 | public Measure(double value) { 15 | init(getDefaultUnit(), value); 16 | } 17 | 18 | protected Measure(String string) { 19 | if (string == null) init(); 20 | else { 21 | string = string.trim(); 22 | int separatorPos = string.indexOf(' '); 23 | String u = separatorPos > 0 ? string.substring(separatorPos).trim() : getDefaultUnit(); 24 | if (!isValidUnit(u)) u = getDefaultUnit(); 25 | 26 | double v = getDefaultValue(); 27 | try { 28 | String valueAsString = separatorPos > 0 ? string.substring(0, separatorPos) : string; 29 | valueAsString = valueAsString.replaceAll(",", ""); 30 | v = Double.parseDouble(valueAsString); 31 | } catch (NumberFormatException nfe) {} 32 | 33 | init(u, v); 34 | } 35 | } 36 | 37 | public Measure(String unit, double value) { 38 | init(unit, value); 39 | } 40 | 41 | @Override 42 | public boolean equals(Object obj) { 43 | if (!(obj instanceof Measure)) return false; 44 | Measure anotherMeasure = (Measure) obj; 45 | return unit.equals(anotherMeasure.unit) && value == anotherMeasure.value; 46 | } 47 | 48 | protected String getDefaultUnit() { 49 | return ""; 50 | } 51 | 52 | protected double getDefaultValue() { 53 | return 0.0; 54 | } 55 | 56 | public String getName() { 57 | return name; 58 | } 59 | 60 | public double getValue() { 61 | return value; 62 | } 63 | 64 | private void init() { 65 | init(getDefaultUnit(), getDefaultValue()); 66 | } 67 | 68 | // //////////////////////////////////////////////////////////////////////// 69 | // /// Formatting 70 | // //////////////////////////////////////////////////////////////////////// 71 | 72 | private void init(String unit, double value) { 73 | this.unit = unit == null ? getDefaultUnit() : unit; 74 | this.value = value; 75 | } 76 | 77 | protected boolean isValidUnit(String unit) { 78 | return true; 79 | } 80 | 81 | public void setName(String name) { 82 | this.name = name; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/function/aggregate/MinTest.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | import static ch.lambdaj.Assert.*; 8 | import static org.hamcrest.Matchers.*; 9 | 10 | import org.junit.*; 11 | 12 | /** @author Luca Marrocco */ 13 | public class MinTest { 14 | 15 | @Test 16 | public void testLesserFirst() { 17 | assertThatMin(1, 2, is(equalTo(1))); 18 | assertThatMin(2, 3, is(equalTo(2))); 19 | assertThatMin(3, 4, is(equalTo(3))); 20 | assertThatMin(1, null, is(equalTo(1))); 21 | } 22 | 23 | @Test 24 | public void testGreaterFirst() { 25 | assertThatMin(4, 3, is(equalTo(3))); 26 | assertThatMin(3, 2, is(equalTo(2))); 27 | assertThatMin(2, 1, is(equalTo(1))); 28 | assertThatMin(null, 1, is(equalTo(1))); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/function/aggregate/Money.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.function.aggregate; 2 | 3 | import java.text.*; 4 | 5 | /** 6 | * @author Luca Marrocco 7 | */ 8 | public final class Money extends Measure { 9 | 10 | private final DecimalFormat decimalFormat = new DecimalFormat("#,##0.00"); 11 | 12 | public static Money money(double value) { 13 | return new Money(value); 14 | } 15 | 16 | public static Money money(String money) throws NumberFormatException { 17 | return new Money(money); 18 | } 19 | 20 | public static Money money(String currency, double value) { 21 | return new Money(currency, value); 22 | } 23 | 24 | public Money(double value) { 25 | super(value); 26 | } 27 | 28 | public Money(String money) { 29 | super(money); 30 | } 31 | 32 | public Money(String currency, double value) { 33 | super(currency, value); 34 | } 35 | 36 | public String getCurrency() { 37 | return unit; 38 | } 39 | 40 | @Override 41 | protected String getDefaultUnit() { 42 | return "EUR"; 43 | } 44 | 45 | public double getValue() { 46 | return value; 47 | } 48 | 49 | public String getFormattedValue() { 50 | return decimalFormat.format(value); 51 | } 52 | 53 | @Override 54 | protected boolean isValidUnit(String currency) { 55 | return currency.matches("\\w{3}"); 56 | } 57 | 58 | public boolean lesserThan(Money anotherMoney) { 59 | throwExceptionIfArentComparable(anotherMoney); 60 | return value < anotherMoney.value; 61 | } 62 | 63 | private void throwExceptionIfArentComparable(Money anotherMoney) { 64 | if (value == 0.0 || anotherMoney.value == 0.0) return; 65 | if (anotherMoney.unit.equals(unit)) return; 66 | throw new RuntimeException(this + " and " + anotherMoney + " are not compatible"); 67 | } 68 | 69 | public Money sum(Money anotherMoney) { 70 | throwExceptionIfArentComparable(anotherMoney); 71 | unit = value == 0.0 ? anotherMoney.unit : unit; 72 | value += anotherMoney.value; 73 | return money(unit, value); 74 | } 75 | 76 | public static final class MoneyAggregator extends PairAggregator { 77 | public Money aggregate(Money money1, Money money2) { 78 | return money1.sum(money2); 79 | } 80 | 81 | public Money emptyItem() { 82 | return new Money(0.0); 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/function/aggregate/SumTest.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.aggregate; 6 | 7 | import static ch.lambdaj.Assert.*; 8 | import static org.hamcrest.Matchers.*; 9 | 10 | import org.junit.*; 11 | 12 | /** @author Luca Marrocco */ 13 | public class SumTest { 14 | 15 | @Test 16 | public void testSumNull() { 17 | assertThatSum(null, null, is(equalTo(0.0))); 18 | } 19 | 20 | @Test 21 | public void testSumNumberAndInteger() { 22 | assertThatSum(1, 1, is(equalTo(2))); 23 | assertThatSum(1, null, is(equalTo(1))); 24 | assertThatSum(null, 1, is(equalTo(1))); 25 | } 26 | 27 | @Test 28 | public void testSumNumberAndLong() { 29 | assertThatSum(1l, 1l, is(equalTo(2l))); 30 | assertThatSum(1l, null, is(equalTo(1l))); 31 | assertThatSum(null, 1l, is(equalTo(1l))); 32 | } 33 | 34 | @Test 35 | public void testSumNumberAndFloat() { 36 | assertThatSum(1f, 1f, is(equalTo(2f))); 37 | assertThatSum(1f, null, is(equalTo(1f))); 38 | assertThatSum(null, 1f, is(equalTo(1f))); 39 | } 40 | 41 | @Test 42 | public void testSumNumberAndDouble() { 43 | assertThatSum(1d, 1d, is(equalTo(2d))); 44 | assertThatSum(1d, null, is(equalTo(1d))); 45 | assertThatSum(null, 1d, is(equalTo(1d))); 46 | } 47 | } -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/function/argument/CreatingArgumentFromArrayTest.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.argument; 6 | 7 | import org.junit.*; 8 | 9 | import static org.mockito.Mockito.*; 10 | import static org.junit.Assert.*; 11 | import static org.hamcrest.CoreMatchers.*; 12 | 13 | public class CreatingArgumentFromArrayTest { 14 | 15 | @Test 16 | public void testCreatingArgumentFromArray() { 17 | ICompilationUnit compilationUnit = mock(ICompilationUnit.class); 18 | ICompilationUnit[] units = new ICompilationUnit[] { compilationUnit }; 19 | 20 | ICompilationUnit[] argument = ArgumentsFactory.createArgument(units.getClass()); 21 | 22 | assertThat(argument, is(instanceOf(ICompilationUnit[].class))); 23 | } 24 | 25 | public interface ICompilationUnit { } 26 | 27 | public interface IPackageFragment { 28 | ICompilationUnit[] getCompilationUnits(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/function/argument/InvocationSequenceTest.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.argument; 6 | 7 | import ch.lambdaj.demo.Car; 8 | import ch.lambdaj.demo.Person; 9 | import org.junit.Ignore; 10 | import org.junit.Test; 11 | 12 | import java.util.Collection; 13 | 14 | import static ch.lambdaj.Lambda.on; 15 | import static ch.lambdaj.Lambda.project; 16 | import static java.util.Arrays.asList; 17 | import static junit.framework.Assert.*; 18 | import static org.hamcrest.MatcherAssert.assertThat; 19 | import static org.hamcrest.Matchers.hasItem; 20 | 21 | /** 22 | * @author Mario Fusco 23 | */ 24 | public class InvocationSequenceTest { 25 | 26 | @Test 27 | public void verifyEquals() throws NoSuchMethodException { 28 | final InvocationSequence invocationSequenceCar = new InvocationSequence(Car.class); 29 | final InvocationSequence invocationSequencePerson = new InvocationSequence(Person.class); 30 | assertFalse(invocationSequenceCar.equals(invocationSequencePerson)); 31 | assertFalse(invocationSequenceCar.hashCode() == invocationSequencePerson.hashCode()); 32 | } 33 | 34 | @Test 35 | public void testProject() { 36 | Collection cars = asList(new Car("Ford", "F150", 2011, 200)); 37 | assertThat(project(cars, SimpleBrand.class, on(Car.class)), hasItem(new SimpleBrand("Ford"))); 38 | assertThat(project(cars, SimpleBrand.class, on(Car.class).getBrand()), hasItem(new SimpleBrand("Ford"))); 39 | } 40 | 41 | public static class SimpleBrand { 42 | private String brand; 43 | 44 | public SimpleBrand(Car car) { 45 | this.brand = car.getBrand(); 46 | } 47 | 48 | public SimpleBrand(String brand) { 49 | this.brand = brand; 50 | } 51 | 52 | public String getBrand() { 53 | return brand; 54 | } 55 | 56 | @Override 57 | public boolean equals(final Object o) { 58 | if (this == o) return true; 59 | if (o == null || getClass() != o.getClass()) return false; 60 | 61 | final SimpleBrand that = (SimpleBrand) o; 62 | 63 | if (brand != null ? !brand.equals(that.brand) : that.brand != null) return false; 64 | 65 | return true; 66 | } 67 | 68 | @Override 69 | public int hashCode() { 70 | return brand != null ? brand.hashCode() : 0; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/function/closure/FaillingClosureTest.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.function.closure; 2 | 3 | import org.junit.*; 4 | 5 | import java.util.*; 6 | 7 | import static ch.lambdaj.Lambda.*; 8 | import static junit.framework.Assert.assertEquals; 9 | 10 | /** 11 | * @author Mario Fusco 12 | */ 13 | public class FaillingClosureTest { 14 | 15 | public T speculate(Collection closures){ 16 | T result = null; 17 | boolean found = false; 18 | for (Iterator it = closures.iterator();it.hasNext() && !found;){ 19 | try{ 20 | Closure c = it.next(); 21 | T o = (T) c.apply(new Object[]{}); 22 | if (o != null){ 23 | result = o; 24 | found = true; 25 | } 26 | } catch (Exception ex){ 27 | System.out.println("Some closure failed"); 28 | } 29 | } 30 | return result; 31 | } 32 | 33 | @Test 34 | public void testSpeculation(){ 35 | Integer uno = 1; // Using Integer objects just for example purposes 36 | Integer dos = 2; 37 | Integer tres = null; 38 | Closure goodClosure = closure();{ of(this).sum(uno,dos); } 39 | Closure badClosure = closure();{ of(this).sum(uno,tres); } 40 | List closures = Arrays.asList(goodClosure,badClosure); 41 | /* Looking for the right calculation */ 42 | Integer i = this.speculate(closures); 43 | /* Print whatever the speculation returns */ 44 | assertEquals(i, (Integer)3); 45 | } 46 | 47 | public int sum(Integer uno,Integer dos){ 48 | return uno+dos; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/function/closure/FileParserClosureTest.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.closure; 6 | 7 | import static ch.lambdaj.Lambda.*; 8 | import static org.junit.Assert.*; 9 | 10 | import org.junit.*; 11 | 12 | import java.io.*; 13 | 14 | /** 15 | * @author Mario Fusco 16 | */ 17 | public class FileParserClosureTest { 18 | 19 | private int lineCounter = 0; 20 | 21 | void countNonEmptyLine(String line) { 22 | if (line != null && line.trim().length() > 0) lineCounter++; 23 | } 24 | 25 | @Test 26 | public void testPrintFile() { 27 | Closure1 lineReader = closure(String.class); { of(System.out).println(var(String.class)); } 28 | readFileByLine("commedia.txt", lineReader); 29 | } 30 | 31 | @Test 32 | public void testReadFile() { 33 | StringWriter sw = new StringWriter(); 34 | Closure1 lineReader = closure(String.class); { of(sw).write(var(String.class)); } 35 | readFileByLine("commedia.txt", lineReader); 36 | } 37 | 38 | @Test 39 | public void testCountFile() { 40 | lineCounter = 0; 41 | Closure1 lineReader = closure(String.class); { of(this).countNonEmptyLine(var(String.class)); } 42 | readFileByLine("commedia.txt", lineReader); 43 | assertEquals(9, lineCounter); 44 | } 45 | 46 | private void readFileByLine(String fileName, Closure1 lineReader) { 47 | BufferedReader reader = null; 48 | try { 49 | InputStream stream = getClass().getClassLoader().getResourceAsStream(fileName); 50 | reader = new BufferedReader(new InputStreamReader(stream)); 51 | for (String line = reader.readLine(); line != null; line = reader.readLine()) { 52 | lineReader.apply(line); 53 | } 54 | } catch (IOException ioe) { 55 | throw new RuntimeException("Error while reading file " + fileName, ioe); 56 | } finally { 57 | try { 58 | if (reader != null) reader.close(); 59 | } catch (IOException ioe) { 60 | throw new RuntimeException("Error while closing file reader", ioe); 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/function/closure/FileParserImplicitClosureTest.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.function.closure; 6 | 7 | import static ch.lambdaj.Lambda.*; 8 | import static org.junit.Assert.*; 9 | 10 | import org.junit.*; 11 | 12 | import java.io.*; 13 | 14 | /** 15 | * @author Mario Fusco 16 | */ 17 | public class FileParserImplicitClosureTest { 18 | 19 | private int lineCounter = 0; 20 | 21 | void countNonEmptyLine(String line) { 22 | if (line != null && line.trim().length() > 0) lineCounter++; 23 | } 24 | 25 | @Test 26 | public void testPrintFile() { 27 | readFileByLine("commedia.txt"); { 28 | of(System.out).println(var(String.class)); 29 | } 30 | } 31 | 32 | @Test 33 | public void testReadFile() { 34 | StringWriter sw = new StringWriter(); 35 | readFileByLine("commedia.txt"); { 36 | of(sw).write(var(String.class)); 37 | } 38 | } 39 | 40 | @Test 41 | public void testCountFile() { 42 | lineCounter = 0; 43 | readFileByLine("commedia.txt"); { 44 | of(this).countNonEmptyLine(var(String.class)); 45 | } 46 | assertEquals(9, lineCounter); 47 | } 48 | 49 | private void readFileByLine(String fileName) { 50 | Closure1 lineReader = closure(String.class); 51 | BufferedReader reader = null; 52 | try { 53 | InputStream stream = getClass().getClassLoader().getResourceAsStream(fileName); 54 | reader = new BufferedReader(new InputStreamReader(stream)); 55 | for (String line = reader.readLine(); line != null; line = reader.readLine()) { 56 | lineReader.apply(line); 57 | } 58 | } catch (IOException ioe) { 59 | throw new RuntimeException("Error while reading file " + fileName, ioe); 60 | } finally { 61 | try { 62 | if (reader != null) reader.close(); 63 | } catch (IOException ioe) { 64 | throw new RuntimeException("Error while closing file reader", ioe); 65 | } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/function/matcher/HasArgumentWithValueTest.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.function.matcher; 2 | 3 | import static ch.lambdaj.Lambda.*; 4 | import static org.hamcrest.Matchers.*; 5 | import static org.junit.Assert.*; 6 | 7 | import org.hamcrest.*; 8 | import org.junit.*; 9 | 10 | import ch.lambdaj.mock.*; 11 | 12 | public class HasArgumentWithValueTest { 13 | 14 | @Test 15 | public void testHaving() { 16 | Person me = new Person("Mario", "Fusco", 35); 17 | Person biagio = new Person("Biagio", "Beatrice", 39); 18 | me.setBestFriend(biagio); 19 | 20 | Matcher matcher = having(on(Person.class).getBestFriend().getAge(), is(equalTo(biagio.getAge()))); 21 | assertTrue(matcher.matches(me)); 22 | assertFalse(matcher.matches(biagio)); 23 | 24 | Description description = new StringDescription(); 25 | matcher.describeTo(description); 26 | assertEquals("hasArgument(\"bestFriend.age\", is <39>)", description.toString()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/function/matcher/HasNestedPropertyWithValueTest.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.function.matcher; 2 | 3 | import static ch.lambdaj.function.matcher.HasNestedPropertyWithValue.*; 4 | import static org.hamcrest.Matchers.*; 5 | import static org.junit.Assert.*; 6 | 7 | import org.hamcrest.*; 8 | import org.junit.*; 9 | 10 | import ch.lambdaj.mock.*; 11 | 12 | public class HasNestedPropertyWithValueTest { 13 | 14 | @Test 15 | public void testHasNestedProperty() { 16 | Person me = new Person("Mario", "Fusco", 35); 17 | Person biagio = new Person("Biagio", "Beatrice", 39); 18 | me.setBestFriend(biagio); 19 | 20 | Matcher matcher = hasNestedProperty("bestFriend.age", is(equalTo(biagio.getAge()))); 21 | assertTrue(matcher.matches(me)); 22 | assertFalse(matcher.matches(biagio)); 23 | 24 | Description description = new StringDescription(); 25 | matcher.describeTo(description); 26 | assertEquals("hasProperty(\"bestFriend.age\", is <39>)", description.toString()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/mock/Exposure.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.mock; 6 | 7 | import static ch.lambdaj.Lambda.*; 8 | import static java.util.Arrays.*; 9 | 10 | /** 11 | * @author Mario Fusco 12 | * @author Luca Marrocco 13 | */ 14 | public class Exposure { 15 | private String countryName; 16 | 17 | private String insuredName; 18 | 19 | private String countryIso; 20 | 21 | private String countryFlag; 22 | 23 | public Exposure() {} 24 | 25 | public Exposure(String countryName, String insuredName) { 26 | this.countryName = countryName; 27 | this.insuredName = insuredName; 28 | } 29 | 30 | public String getCountryFlag() { 31 | return countryFlag; 32 | } 33 | 34 | public String getCountryIso() { 35 | return countryIso; 36 | } 37 | 38 | public String getCountryName() { 39 | return countryName; 40 | } 41 | 42 | public String getInsuredName() { 43 | return insuredName; 44 | } 45 | 46 | public void setCountryFlag(String countryFlag) { 47 | this.countryFlag = countryFlag; 48 | } 49 | 50 | public void setCountryIso(String countryIso) { 51 | this.countryIso = countryIso; 52 | } 53 | 54 | public void setCountryName(String countryName) { 55 | this.countryName = countryName; 56 | } 57 | 58 | public void setInsuredName(String insuredName) { 59 | this.insuredName = insuredName; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return join(forEach(asList(countryName, insuredName))); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/mock/ExposureBy.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.mock; 6 | 7 | import ch.lambdaj.group.*; 8 | 9 | /** 10 | * @author Mario Fusco 11 | * @author Luca Marrocco 12 | */ 13 | @SuppressWarnings("serial") 14 | public class ExposureBy extends GroupConditions { 15 | 16 | public static ExposureBy byExposure() { 17 | return new ExposureBy(); 18 | } 19 | 20 | public ExposureBy insuredName() { 21 | by("insuredName"); 22 | return this; 23 | } 24 | 25 | public ExposureBy countryName() { 26 | by("countryName"); 27 | return this; 28 | } 29 | 30 | public ExposureBy asInsureds() { 31 | as("insureds"); 32 | return this; 33 | } 34 | 35 | public ExposureBy asCountries() { 36 | as("countries"); 37 | return this; 38 | } 39 | 40 | public ExposureBy asExposures() { 41 | as("exposures"); 42 | return this; 43 | } 44 | 45 | public ExposureBy headCountryIso() { 46 | head("countryIso"); 47 | return this; 48 | } 49 | 50 | public ExposureBy headCountryIsoAsCode() { 51 | head("countryIso", "code"); 52 | return this; 53 | } 54 | } -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/mock/IPerson.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.mock; 2 | 3 | import java.util.*; 4 | 5 | public interface IPerson { 6 | public enum Gender { 7 | MALE, FEMALE 8 | } 9 | 10 | Gender getGender(); 11 | 12 | String getFirstName(); 13 | void setFirstName(String firstName); 14 | 15 | String getLastName(); 16 | void setLastName(String lastName); 17 | 18 | int getAge(); 19 | void setAge(int age); 20 | 21 | Date getBirthDate(); 22 | 23 | IPerson getBestFriend(); 24 | void setBestFriend(IPerson bestFriend); 25 | 26 | boolean isYoungerThan(int maxAge); 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/mock/PersonDto.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.mock; 2 | 3 | /** 4 | * @author Mario Fusco 5 | */ 6 | public class PersonDto { 7 | 8 | private final String name; 9 | private final int age; 10 | 11 | public PersonDto(String name, int age) { 12 | this.name = name; 13 | this.age = age; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public int getAge() { 21 | return age; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/mock/PersonThrowingException.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.mock; 2 | 3 | public class PersonThrowingException extends Person { 4 | @Override 5 | public void setLastName(String lastName) { 6 | throw new RuntimeException("Cannot set last name"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/mock/ReturnAString.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.mock; 6 | 7 | /** 8 | * @author Mario Fusco 9 | * @author Luca Marrocco 10 | */ 11 | public interface ReturnAString { 12 | String aString(); 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/mock/Text.java: -------------------------------------------------------------------------------- 1 | // Modified or written by Lambdascale SRL for inclusion with lambdaj. 2 | // Copyright (c) 2009-2010 Mario Fusco. 3 | // Licensed under the Apache License, Version 2.0 (the "License") 4 | 5 | package ch.lambdaj.mock; 6 | 7 | /** 8 | * @author Mario Fusco 9 | * @author Luca Marrocco 10 | */ 11 | public class Text { 12 | private String string; 13 | 14 | public Text() {} 15 | 16 | public Text(String string) { 17 | this.string = string; 18 | } 19 | 20 | public int length() { 21 | return string.length(); 22 | } 23 | 24 | public Text subString(int begin, int end) { 25 | return new Text(string.substring(begin, end)); 26 | } 27 | 28 | @Override 29 | public boolean equals(Object obj) { 30 | return obj instanceof Text && string.equals(((Text) obj).string); 31 | } 32 | 33 | @Override 34 | public int hashCode() { 35 | return string.hashCode(); 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return string; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/mock/ValidatingPersonDto.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.mock; 2 | 3 | public class ValidatingPersonDto extends PersonDto { 4 | 5 | public ValidatingPersonDto(String name, int age) { 6 | super(name, age); 7 | if (age > 30) throw new RuntimeException("too young!"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/proxy/nodefconstructor/ElementId.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.proxy.nodefconstructor; 2 | 3 | public class ElementId { 4 | private String elementID; 5 | 6 | public ElementId(final String elementID) { 7 | this.elementID = elementID; 8 | } 9 | 10 | public String getString() { 11 | return elementID; 12 | } 13 | 14 | public int intValue() { 15 | return Integer.parseInt(elementID); 16 | } 17 | 18 | public void setValue(final String id) { 19 | elementID = id; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return elementID; 25 | } 26 | 27 | @Override 28 | public int hashCode() { 29 | final int prime = 31; 30 | int result = 1; 31 | result = prime * result 32 | + ((elementID == null) ? 0 : elementID.hashCode()); 33 | return result; 34 | } 35 | 36 | @Override 37 | public boolean equals(final Object obj) { 38 | if (this == obj) { 39 | return true; 40 | } 41 | if (obj == null) { 42 | return false; 43 | } 44 | if (getClass() != obj.getClass()) { 45 | return false; 46 | } 47 | ElementId other = (ElementId) obj; 48 | if (elementID == null) { 49 | if (other.elementID != null) { 50 | return false; 51 | } 52 | } else if (!elementID.equals(other.elementID)) { 53 | return false; 54 | } 55 | return true; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/proxy/nodefconstructor/ProxyNoDefaultConstructorTest.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.proxy.nodefconstructor; 2 | 3 | import java.util.Arrays; 4 | 5 | import org.junit.*; 6 | import static ch.lambdaj.Lambda.*; 7 | import static org.hamcrest.CoreMatchers.*; 8 | 9 | public class ProxyNoDefaultConstructorTest { 10 | 11 | @Test 12 | public void testProxyNoDefaultConstructor() { 13 | RelationMetricResult firstSuspect = new RelationMetricResult(new ElementId("1"), new ElementId("2"), 1.0); 14 | RelationMetricResult secondSuspect = new RelationMetricResult(new ElementId("2"), new ElementId("3"), 2.0); 15 | Iterable suspects = Arrays.asList(firstSuspect, secondSuspect); 16 | 17 | RelationMetricResult selected = selectFirst(suspects, 18 | having(on(RelationMetricResult.class).from().intValue(), 19 | equalTo(2))); 20 | assert(secondSuspect.equals(selected)); 21 | } 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/proxy/nodefconstructor/RelationMetricResult.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.proxy.nodefconstructor; 2 | 3 | 4 | 5 | public class RelationMetricResult { 6 | private final ElementId from; 7 | private final ElementId to; 8 | private final double metric; 9 | 10 | //protected RelationMetricResult() {} 11 | 12 | public RelationMetricResult(ElementId from, ElementId to, double metric) { 13 | this.from = from; 14 | this.to = to; 15 | this.metric = metric; 16 | } 17 | 18 | public ElementId from() { 19 | return this.from; 20 | } 21 | 22 | public ElementId to() { 23 | return this.to; 24 | } 25 | 26 | public double getMetricValue() { 27 | return this.metric; 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return String.valueOf(getMetricValue()); 33 | } 34 | 35 | public boolean isForRelation(ElementId from, ElementId to) { 36 | return this.from.equals(from) && this.to.equals(to); 37 | } 38 | 39 | public Integer intFrom() { 40 | return from().intValue(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/proxy/nodefconstructor/problem/ElementId.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.proxy.nodefconstructor.problem; 2 | 3 | public class ElementId { 4 | private String elementID; 5 | 6 | public ElementId(final String elementID) { 7 | this.elementID = elementID; 8 | } 9 | 10 | public String getString() { 11 | return elementID; 12 | } 13 | 14 | public int intValue() { 15 | return Integer.parseInt(elementID); 16 | } 17 | 18 | public void setValue(final String id) { 19 | elementID = id; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return elementID; 25 | } 26 | 27 | @Override 28 | public int hashCode() { 29 | final int prime = 31; 30 | int result = 1; 31 | result = prime * result 32 | + ((elementID == null) ? 0 : elementID.hashCode()); 33 | return result; 34 | } 35 | 36 | @Override 37 | public boolean equals(final Object obj) { 38 | if (this == obj) { 39 | return true; 40 | } 41 | if (obj == null) { 42 | return false; 43 | } 44 | if (getClass() != obj.getClass()) { 45 | return false; 46 | } 47 | ElementId other = (ElementId) obj; 48 | if (elementID == null) { 49 | if (other.elementID != null) { 50 | return false; 51 | } 52 | } else if (!elementID.equals(other.elementID)) { 53 | return false; 54 | } 55 | return true; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/proxy/nodefconstructor/problem/RelationSmell.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.proxy.nodefconstructor.problem; 2 | 3 | 4 | public class RelationSmell { 5 | private final ElementId from; 6 | private final ElementId to; 7 | 8 | public RelationSmell(final ElementId from, final ElementId to) { 9 | super(); 10 | this.from = from; 11 | this.to = to; 12 | } 13 | 14 | public ElementId getFrom() { 15 | return from; 16 | } 17 | 18 | public ElementId getTo() { 19 | return to; 20 | } 21 | 22 | public boolean isForRelation(final ElementId from, final ElementId to) { 23 | return this.from.equals(from) && this.to.equals(to); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/proxy/nodefconstructor/problem/RelationSmellQuery.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.proxy.nodefconstructor.problem; 2 | 3 | import static ch.lambdaj.Lambda.on; 4 | import static ch.lambdaj.Lambda.selectFirst; 5 | import static ch.lambdaj.function.matcher.HasArgumentWithValue.havingValue; 6 | import static org.hamcrest.CoreMatchers.is; 7 | import static org.junit.Assert.assertThat; 8 | 9 | import java.util.ArrayList; 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | import org.junit.Test; 14 | 15 | 16 | public class RelationSmellQuery { 17 | 18 | private List smells = new ArrayList(); 19 | 20 | public RelationSmell getSmellForID(final ElementId from, final ElementId to) { 21 | return selectFirst(smells, 22 | havingValue(on(RelationSmell.class).isForRelation(from, to))); 23 | /* 24 | * return Collections2.findFirstOrDefault(smells, new 25 | * Predicate() { 26 | * public boolean apply(final RelationSmell smell) { 27 | * return smell.isForRelation(from, to); 28 | * }}); 29 | */ 30 | } 31 | 32 | @Test 33 | public void when_selecting_first_element_for_relation_smell_query_should_not_throw() { 34 | RelationSmell smell_between_1_and_1 = 35 | new RelationSmell(new ElementId("1"), new ElementId("2")); 36 | 37 | RelationSmell smell_between_3_and_4 = 38 | new RelationSmell(new ElementId("3"), new ElementId("4")); 39 | 40 | smells = Arrays.asList( 41 | smell_between_1_and_1, 42 | smell_between_3_and_4, 43 | smell_between_1_and_1); 44 | 45 | ElementId from = new ElementId("3"); 46 | ElementId to = new ElementId("4"); 47 | 48 | RelationSmell smell = getSmellForID(from, to); 49 | 50 | assertThat(smell, is(smell_between_3_and_4)); 51 | } 52 | 53 | public boolean hasSmellForID(final ElementId from, final ElementId to) { 54 | return getSmellForID(from, to) != null; 55 | } 56 | 57 | public RelationSmellQuery() { 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/test/java/ch/lambdaj/util/iterator/IteratorFactoryTest.java: -------------------------------------------------------------------------------- 1 | package ch.lambdaj.util.iterator; 2 | 3 | import org.junit.*; 4 | import static org.junit.Assert.*; 5 | 6 | import static java.util.Arrays.asList; 7 | import java.util.*; 8 | 9 | /** 10 | * @author Mario Fusco 11 | */ 12 | public class IteratorFactoryTest { 13 | 14 | @Test 15 | public void testInvalidIterator() { 16 | try { 17 | IteratorFactory.asIterator("xxx"); 18 | fail("asIterator on a non-collection must fail"); 19 | } catch (IllegalArgumentException iae) { } 20 | try { 21 | IteratorFactory.asResettableIterator("xxx"); 22 | fail("asResettableIterator on a non-collection must fail"); 23 | } catch (IllegalArgumentException iae) { } 24 | } 25 | 26 | @Test 27 | public void testResettableIteratorOnIterator() { 28 | ResettableIterator iterator = (ResettableIterator)IteratorFactory.asResettableIterator(asList("one", "two", "three").iterator()); 29 | try { 30 | iterator.remove(); 31 | fail("remove invocation on resattable iterator must fail"); 32 | } catch (UnsupportedOperationException uoe) { } 33 | 34 | assertEquals("one", iterator.next()); 35 | assertEquals("two", iterator.next()); 36 | iterator.reset(); 37 | assertEquals("one", iterator.next()); 38 | assertEquals("two", iterator.next()); 39 | assertEquals("three", iterator.next()); 40 | 41 | try { 42 | iterator.next(); 43 | fail("next invocation after last item must fail"); 44 | } catch (NoSuchElementException nse) { } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/resources/commedia.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mariofusco/lambdaj/bd3afc7c084c3910454a793a872b0a76f92a43fd/src/test/resources/commedia.txt --------------------------------------------------------------------------------