[BAEL-16640] - Split or move core-java-modules/core-java-lang-syntax module
This commit is contained in:
@@ -4,7 +4,6 @@ This module contains articles about Java syntax
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Java ‘private’ Access Modifier](https://www.baeldung.com/java-private-keyword)
|
||||
- [Guide to Java Packages](https://www.baeldung.com/java-packages)
|
||||
- [If-Else Statement in Java](https://www.baeldung.com/java-if-else)
|
||||
- [Control Structures in Java](https://www.baeldung.com/java-control-structures)
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.baeldung.core.privatemodifier;
|
||||
|
||||
public class Employee {
|
||||
|
||||
private String privateId;
|
||||
private String name;
|
||||
private boolean manager;
|
||||
|
||||
public Employee(String id, String name) {
|
||||
setPrivateId(id);
|
||||
setName(name);
|
||||
}
|
||||
|
||||
private Employee(String id, String name, boolean managerAttribute) {
|
||||
this.privateId = id;
|
||||
this.name = name;
|
||||
this.privateId = id + "_ID-MANAGER";
|
||||
}
|
||||
|
||||
public void setPrivateId(String customId) {
|
||||
if (customId.endsWith("_ID")) {
|
||||
this.privateId = customId;
|
||||
} else {
|
||||
this.privateId = customId + "_ID";
|
||||
}
|
||||
}
|
||||
|
||||
public String getPrivateId() {
|
||||
return privateId;
|
||||
}
|
||||
|
||||
public boolean isManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
public void elevateToManager() {
|
||||
if ("Carl".equals(this.name)) {
|
||||
setManager(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void setManager(boolean manager) {
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static Employee buildManager(String id, String name) {
|
||||
return new Employee(id, name, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.baeldung.core.privatemodifier;
|
||||
|
||||
public class ExampleClass {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Employee employee = new Employee("Bob","ABC123");
|
||||
employee.setPrivateId("BCD234");
|
||||
System.out.println(employee.getPrivateId());
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.baeldung.core.privatemodifier;
|
||||
|
||||
public class PublicOuterClass {
|
||||
|
||||
public PrivateInnerClass getInnerClassInstance() {
|
||||
PrivateInnerClass myPrivateClassInstance = this.new PrivateInnerClass();
|
||||
myPrivateClassInstance.id = "ID1";
|
||||
myPrivateClassInstance.name = "Bob";
|
||||
return myPrivateClassInstance;
|
||||
}
|
||||
|
||||
private class PrivateInnerClass {
|
||||
public String name;
|
||||
public String id;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user