This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List watchedGetChildren(CuratorFramework client, String path) throws Exception { | |
return client.getChildren() | |
.usingWatcher(new WatcherImpl(client,path)) | |
.forPath(path); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String getData(CuratorFramework client, String path) throws Exception{ | |
String str = new String(client.getData() | |
.usingWatcher(new WatcherImpl(client,path)) | |
.forPath(path)); | |
return str; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WatcherImpl implements Watcher{ | |
@Override | |
public void process(WatchedEvent event) { | |
if(event.getType() == Event.EventType.NodeDataChanged) { | |
System.out.println("The Data has changed"); | |
} | |
else if(event.getType() == Event.EventType.NodeChildrenChanged){ | |
System.out.println("Children have changed"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
//Constructor of A | |
A() { | |
System.out.println("A's constructor"); | |
} | |
public void method() { | |
System.out.println("A's get method"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class B extends A{ | |
//Constructor of B | |
B(){ | |
System.out.println("B's constructor"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
System.out.println("JAVA - INHERITANCE"); | |
B objectB = new B(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JAVA - INHERITANCE | |
A's constructor | |
B's constructor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class B extends A{ | |
//Constructor of B | |
B(){ | |
System.out.println("B's constructor"); //This is not allowed | |
super(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class B extends A{ | |
//Constructor of B | |
B(){ | |
super(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class B extends A{ | |
//Constructor of B | |
B(){ | |
super(); | |
} | |
@Override | |
public void method(){ | |
System.out.println("B's get method"); | |
super.method(); |