先贴代码:
DuplicateCenter { main(String[] args) { List names = Arrays.()names=ImmutableSet.( Iterables.( namesPredicates.(Predicates.()))).asList()Iterable filtered = Iterables.( Iterables.(names(()()))())IteratornameIterator=filtered.iterator()(nameIterator.hasNext()){ System..println(nameIterator.next())} } LengthLessThanPredicate Predicate { LengthLessThanPredicate(length) { .= length} apply(String s) { s.length() < } } OrPredicate Predicate { Predicate Predicate OrPredicate(Predicate SPredicate T){ .=S.=T} apply(String s) { .apply(s)||.apply(s)} } Predicate lengthLessThan(length) { LengthLessThanPredicate(length)} Predicate or(Predicate SPredicate T){ OrPredicate(ST)} Predicate isEqualTo(String str){ EqualtoPredicate(str)} EqualtoPredicate Predicate { String EqualtoPredicate(String str) { .=str} apply(String s) { s.equals()} }}
FluentIterable<> Iterable<> { Iterable<> FluentIterable(Iterable<> iterable) { .= iterable} <> FluentIterable<> with(Iterable<> iterable) { FluentIterable<>(iterable)} Iterator<> iterator() { ..iterator()} FluentIterable<> filter(Predicate predicate) { Iterable filtered = Iterables.(.predicate).= filtered}}
函数式编程的样子
很明朗有没有