concept operation in category java

This is an excerpt from Manning's book JUnit in Action.
Listing 2.18 Repeated tests
public class RepeatedTestsTest { private static Set<Integer> integerSet = new HashSet<>(); private static List<Integer> integerList = new ArrayList<>(); @RepeatedTest(value = 5, name = #1 "{displayName} - repetition {currentRepetition}/{totalRepetitions}") #1 @DisplayName("Test add operation") void addNumber() { Calculator calculator = new Calculator(); assertEquals(2, calculator.add(1, 1), "1 + 1 should equal 2"); } @RepeatedTest(value = 5, name = "the list contains #2 {currentRepetition} elements(s), the set contains 1 element") #2 void testAddingToCollections(TestReporter testReporter, RepetitionInfo repetitionInfo) { integerSet.add(1); integerList.add(repetitionInfo.getCurrentRepetition()); testReporter.publishEntry("Repetition number", #3 String.valueOf(repetitionInfo.getCurrentRepetition())); #3 assertEquals(1, integerSet.size()); assertEquals(repetitionInfo.getCurrentRepetition(), integerList.size()); } }
Creating a RESTful API to manage two related entities—the country and the passenger—and executing GET, PATCH, DELETE, and POST operations against it to get the list of passengers; to get a particular passenger by ID; and to create, update, or delete a passenger Testing the RESTful API that manages two related entities by creating and executing tests against a Spring REST MockMvc object to test the previously mentioned GET, PATCH, DELETE, and POST operations

This is an excerpt from Manning's book Modern Java in Action: Lambdas, streams, reactive and functional programming.
But, for reasons centered on better exploiting parallelism, the designers didn’t do this. Java 8 instead contains a new Collection-like API called Stream, containing a comprehensive set of operations similar to the filter operation that functional programmers may be familiar with (for example, map and reduce), along with methods to convert between Collections and Streams, which we now investigate.
The code is written in a declarative way: you specify what you want to achieve (filter dishes that are low in calories) as opposed to specifying how to implement an operation (using control-flow blocks such as loops and if conditions). As you saw in the previous chapter, this approach, together with behavior parameterization, enables you to cope with changing requirements: you could easily create an additional version of your code to filter high-calorie dishes using a lambda expression, without having to copy and paste code. Another way to think about the benefit of this approach is that the threading model is decoupled from the query itself. Because you are providing a recipe for a query, it could be executed sequentially or in parallel. You will learn more about this in chapter 7. You chain together several building-block operations to express a complicated data-processing pipeline (you chain the filter by linking sorted, map, and collect operations, as illustrated in figure 4.1) while keeping your code readable and its intent clear. The result of the filter is passed to the sorted method, which is then passed to the map method and then to the collect method. Because operations such as filter (or sorted, map, and collect) are available as high-level building blocks that don’t depend on a specific threading model, their internal implementation could be single-threaded or could potentially maximize your multicore architecture transparently! In practice, this means you no longer have to worry about threads and locks to figure out how to parallelize certain data processing tasks: the Streams API does it for you!
Streams make use of internal iteration: the iteration is abstracted away through operations such as filter, map, and sorted.

This is an excerpt from Manning's book Functional Programming in Java: How functional techniques improve your Java programs.
This method of List uses an operation to reduce the list to a single value. This operation is represented by Function<A, Function<A, A>> f. This notation may look a bit weird, but you’ll learn what it means in chapter 2. It could be, for example, an addition. In such a case, it would simply mean a function such as f(a, b) = a + b.
You can fold a list in two directions, from left to right or from right to left, depending on the operation used:
If the operation is commutative, both ways of folding are equivalent. If the operation isn’t commutative, the two ways of folding give different results. Folding needs a starting value, which is the neutral element, or identity element, for the operation. This element is used as the starting value of the accumulator. When the computation is complete, the accumulator contains the result. Reducing, on the other hand, can be done without a starting element, with the condition that the list isn’t empty, because the first (or last) element will be used as the starting element.
In this example, an operation is applied to each element of an Integer list (integerList) to increase it by 20%. The result of the operation is a double, so it’s put in a new list that’s created before the start of the loop. Although simple, this program raises some interesting questions.
process operation if the operation is a deposit add the amount to the account and add the operation to the operation list process next operation if the operation is a withdraw and the amount is less than the account balance remove the amount from the account and add the operation to the operation list process next operation else do not change account nor operation list

This is an excerpt from Manning's book Java 8 in Action: Lambdas, streams, and functional-style programming.
But, for reasons centered on better exploiting parallelism, the designers didn’t do this. Java 8 instead contains a whole new Collections-like API called Streams, containing a comprehensive set of operations similar to filter that functional programmers may be familiar with (for example, map, reduce), along with methods to convert between Collections and Streams, which we now investigate.
The code is written in a declarative way: you specify what you want to achieve (that is, filter dishes that are low in calories) as opposed to specifying how to implement an operation (using control-flow blocks such as loops and if conditions). As you saw in the previous chapter, this approach, together with behavior parameterization, enables you to cope with changing requirements: you could easily create an additional version of your code to filter high-calorie dishes using a lambda expression, without having to copy and paste code. You chain together several building-block operations to express a complicated data processing pipeline (you chain the filter by linking sorted, map, and collect operations, as illustrated in figure 4.1) while keeping your code readable and its intent clear. The result of the filter is passed to the sorted method, which is then passed to the map method and then to the collect method. Because operations such as filter (or sorted, map, and collect) are available as high-level building blocks that don’t depend on a specific threading model, their internal implementation could be single-threaded or potentially maximize your multicore architecture transparently! In practice, this means you no longer have to worry about threads and locks to figure out how to parallelize certain data processing tasks: the Streams API does it for you!

This is an excerpt from Manning's book Spring Integration in Action.
The message channel is the connection between multiple endpoints. The channel implementation manages the details of how and where a message is delivered but shouldn’t need to interact with the payload of a message. Whereas the most important characteristic of any channel is that it logically decouples producers from consumers, there are a number of practical implementation options. For example, a particular channel implementation might dispatch messages directly to passive consumers within the same thread of control. On the other hand, a different channel implementation might buffer messages in a queue whose reference is shared by the producer and an active consumer such that the send and receive operations each occur within different threads of control. Additionally, channels may be classified according to whether messages are delivered to a single endpoint (point-to-point) or to any endpoint that is listening to the channel (publish-subscribe). As mentioned earlier, regardless of the implementation details, the main goal of any message channel is to decouple the message endpoints on both sides from each other and from any concerns of the underlying transport.
JMX is a standard way of exposing runtime information about a running Java application to allow monitoring and runtime management of the application. Attributes exposed via JMX can either be read-only, such as the number of messages on a queue, or read-write, such as the maximum number of database connections allowed in a connection pool. As well as exposing attributes, JMX allows operations to be exposed. Each operation relates directly to a Java method invocation with zero or more parameters. In addition to operations and attributes, JMX has a concept of notifications, which are essentially events emitted by a component. These are typically used to notify listeners of some sort of problem rather than a more general form of interprocess or intercom-ponent communication. One of the advantages of using JMX is the tooling support: many monitoring systems support JMX, allowing operations teams to use the tooling they may already use to monitor hardware to also monitor Java applications that expose information via JMX. Where JMX isn’t directly supported, it’s also possible to map some of the JMX concepts to other monitoring technologies; for example, JMX notifications can be mapped to SNMP (Simple Network Management Protocol) traps.

This is an excerpt from Manning's book The Well-Grounded Java Developer.
Although the NIO.2 APIs offer much improved support for atomic operations, it still pays to code defensively when dealing with a filesystem. Even when an operation is midflight, it’s all too easy for a network share to fail, a cup of coffee to be spilled on a server, or (in the case of an infamous incident by one of the authors) the shutdown now command to be executed on the wrong UNIX box. The API does throw RuntimeException from some of its methods, but some exceptional cases can be mitigated by helper methods such as Files.exists(Path).
The walkFileTree method doesn’t automatically follow symbolic links, making operations like recursion safer. If you do need to follow symbolic links, you’ll need to detect that attribute (as discussed in section 2.4.3) and act on it accordingly.
Now that you’re comfortable with paths and directory trees, it’s time to move on from the manipulation of locations to performing operations on the actual filesystem itself, using the new Files class and friends.

This is an excerpt from Manning's book AspectJ in Action, Second Edition.
Surround the operation with a try/catch block to perform an exception-handling policy (for example, transaction management)
The read-write lock pattern offers maximal liveliness while ensuring the integrity of objects. It’s an appropriate pattern in situations where you expect the reader threads to access the object more frequently than the writer threads, and the operations are expensive (to justify the use of acquiring and releasing locks). The fundamental idea is that any number of readers can simultaneously read the state of the object as long as no thread is modifying the state at the same time.
In the first version of the solution, you route all the calls through EventQueue.invokeAndWait(). With this arrangement, the caller is blocked until the event-dispatching thread executes the operation. In practice, blocking the caller is often undesirable and should be limited to situations that warrant its usage. But the implementation does provide a simple solution to ensure compliance with Swing’s single-thread rule. Later, you’ll improve on this solution. Listing 13.4 shows the base abstract aspect that routes all join points selected by the uiCall() pointcut synchronously.
Executing operation synchronously Executing: void javax.swing.JFrame.setDefaultCloseOperation(int) Thread[AWT-EventQueue-0,6,main] Executing operation synchronously Executing: Container javax.swing.JFrame.getContentPane() Thread[AWT-EventQueue-0,6,main] Executing operation synchronously Executing: void javax.swing.JFrame.pack() Thread[AWT-EventQueue-0,6,main] Executing operation synchronously Executing: void javax.swing.JFrame.setVisible(boolean) Thread[AWT-EventQueue-0,6,main] Executing operation synchronously Executing: void javax.swing.table.DefaultTableModel.setValueAt(Object, int, int) Thread[AWT-EventQueue-0,6,main] Executing operation synchronously Executing: void javax.swing.JOptionPane.showMessageDialog(Component, Object) Thread[AWT-EventQueue-0,6,main] Executing operation synchronously Executing: int javax.swing.table.DefaultTableModel.getRowCount() Thread[AWT-EventQueue-0,6,main] Row count = 4 Executing operation synchronously Executing: Color javax.swing.JTable.getGridColor() Thread[AWT-EventQueue-0,6,main] Grid color = javax.swing.plaf.ColorUIResource[r=122,g=138,b=153]