Java underlying series: Look College class in java.util thought through OOP and AOP

OOP (Object Oriented Programming): Object-Oriented Programming;

AOP (Aspect Oriented Programming): Oriented Programming;

If OOP is a longitudinal, then transverse AOP is; if OOP is horizontal, then the AOP is the longitudinal direction. In short, they are crossed, a main line, an episode.

17138799-9aa6d6da3b2044f8
Java underlying series: Look College class in java.util thought through OOP and AOP

figure 1

In Figure 1, there are the following interfaces, they are declared with annotations @FunctionalInterface, which represents a certain function, as follows,

interface Comparator <T>: Comparator

interface Function <T, R & lt>: Represents by the accepts A function that Produces A One argument and result, R & lt representatives result, there is an intake represents a (input return value) of functional objects

interface Consumer <T>:. Represents by AN Operation argument that the accepts A SINGLE INPUT NO Result and Returns that Unlike the interfaces Functional MOST OTHER, IS} {@code Consumer expected to Operate Via Side-Effects, showing no one has an inlet (with no input return value) consumed objects

interface the Predicate <T>: Represents by the predicateA A (Boolean-valued function) One of argument, if the determination indicates that the verb objects

interface Supplier <T>: Results of Represents by Supplier A, T represents a target result output type objects

17138799-9d00f4cc3ca3dca3
Java underlying series: Look College class in java.util thought through OOP and AOP

2, the strip type upward pointing arrow method returns, the downward pointing arrow subclass

FIG 2 is a collection class object, as follows

final class Optional <T>: A container object which may or may not contain a non-null value may contain a value of the target container.

Iterator <E>:. An iterator over a collection set an iterator

interface Iterable <T>: Implementing this interface allows an object to be the target of spreading the "foreach loop" statement, iterator, the element T into the foreach iteration, no return

<pre style="-webkit-tap-highlight-color: transparent; box-sizing: border-box; font-family: Consolas, Menlo, Courier, monospace; font-size: 16px; white-space: pre-wrap; position: relative; line-height: 1.5; color: rgb(153, 153, 153); margin: 1em 0px; padding: 12px 10px; background: rgb(244, 245, 246); border: 1px solid rgb(232, 232, 232); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">public interface Iterable<T> {
 Iterator<T> iterator();
 default void forEach(Consumer<? super T> action) {
 Objects.requireNonNull(action);
 for (T t : this) {
 action.accept(t);
 }
 }
 default Spliterator<T> spliterator() {
 return Spliterators.spliteratorUnknownSize(iterator(), 0);
 }
 }
</pre>

interface Stream:. A sequence of elements supporting sequential and parallel aggregate operations a target sequence of elements, supported in parallel, order, etc. polymerization operation.

interface Collection <E>:. The root interface in the collection hierarchy of the root interface collections

1, the iterator to the collection, the iterator to the sequence flow, OPP reflects a thought, the relationship between objects, parent-child inheritance, the method returns the value or relationship; regardless iterators, stream , or set, useful for the functional objects are more or less in FIG. 2 to achieve a partial cut, as defined in the Consumer Iterable above, it is a thinking AOP.

Reproduced in: https: //www.jianshu.com/p/fb75b6932aa6

Guess you like

Origin blog.csdn.net/weixin_34208185/article/details/91303292