Tutorial by Examples: ann

// Connect to a target server using your ConnectionMultiplexer instance IServer server = conn.GetServer("localhost", 6379); // Write out each key in the server foreach(var key in server.Keys()) { Console.WriteLine(key); }
The Standard Edition of Java comes with some annotations predefined. You do not need to define them by yourself and you can use them immediately. They allow the compiler to enable some fundamental checking of methods, classes and code. @Override This annotation applies to a method and says that th...
Scanner scanner = new Scanner(System.in); //Scanner obj to read System input String inputTaken = new String(); while (true) { String input = scanner.nextLine(); // reading one line of input if (input.matches("\\s+")) // if it matches spaces/tabs, stop reading b...
Scanner scanner = null; try { scanner = new Scanner(new File("Names.txt")); while (scanner.hasNext()) { System.out.println(scanner.nextLine()); } } catch (Exception e) { System.err.println("Exception occurred!"); } finally { if (scanner != nul...
Java's Reflection API allows the programmer to perform various checks and operations on class fields, methods and annotations during runtime. However, in order for an annotation to be at all visible at runtime, the RetentionPolicy must be changed to RUNTIME, as demonstrated in the example below: @i...
You can use Scanner to read all of the text in the input as a String, by using \Z (entire input) as the delimiter. For example, this can be used to read all text in a text file in one line: String content = new Scanner(new File("filename")).useDelimiter("\\Z").next(); System.o...
When it comes to adding/removing channels to/from your channel groups, you need to have must have the manage permission for those channel groups. But you should never grant clients the permission to manage the channel groups that they will subscribe to. If they did, then they could add any channel t...
With Stream Controller add-on enabled, you can use Channel Groups to subscribe to a 1000's of channels from a single client. You do this by creating a channel group and adding channels to the channel group. We'll assume pubnub variable has been initialized properly with your keys. Create a generic ...
A stub is a light weight test double that provides canned responses when methods are called. Where a class under test relies on an interface or base class an alternative 'stub' class can be implemented for testing which conforms to the interface. So, assuming the following interface, public inter...
Annotation types are defined with @interface. Parameters are defined similar to methods of a regular interface. @interface MyAnnotation { String param1(); boolean param2(); int[] param3(); // array parameter } Default values @interface MyAnnotation { String param1() defau...
Table cells can span multiple columns or rows using the colspan and rowspan attributes. These attributes can be applied to <th> and <td> elements. <table> <tr> <td>row 1 col 1</td> <td>row 1 col 2</td> <td>row 1 c...
Documentation comments are placed directly above the method or class they describe. They begin with three forward slashes ///, and allow meta information to be stored via XML. /// <summary> /// Bar method description /// </summary> public void Bar() { } Information in...
Announcements are useful for alerting users to events that don’t require any interaction, such as “screen locked” or “finished loading.” Use a more specific announcement to notify users of screen changes or more minor layout changes. UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotifi...
Reading a file line by line public class Main { public static void main(String[] args) { try { Scanner scanner = new Scanner(new File("example.txt")); while(scanner.hasNextLine()) { String line = scanner.nextLine(); ...
Unlike classes, structures cannot inherit: class MyView: NSView { } // works struct MyInt: Int { } // error: inheritance from non-protocol type 'Int' Structures, however, can adopt protocols: struct Vector: Hashable { ... } // works
If an object is defined with static, thread, or automatic storage duration, and it has a character type, either: char, unsigned char, or signed char, it may not be accessed by a non-character type. In the below example a char array is reinterpreted as the type int, and the behavior is undefined on e...
Channels can be used to send data from one thread to another. Below is an example of a simple producer-consumer system, where the main thread produces the values 0, 1, ..., 9, and the spawned thread prints them: use std::thread; use std::sync::mpsc::channel; fn main() { // Create a channel...
The class we are going to test is: public class Service{ private Collaborator collaborator; public Service(Collaborator collaborator){ this.collaborator = collaborator; } public String performService(String input){ return collaborator.transformS...
Equivalently, we can use the $inject property annotation to achieve the same as above: var MyController = function($scope) { // ... } MyController.$inject = ['$scope']; myModule.controller('MyController', MyController);
beacon = CLBeaconRegion(proximityUUID: <#NSUUID#>, major: <#CLBeaconMajorValue#>, identifier: <#String#>) // listening to all beacons with given UUID and major value beacon = CLBeaconRegion(proximityUUID: <##NSUUID#>, major: <##CLBeaconMajorValue#>, minor: <##C...

Page 1 of 7