Add Java annotation to code blocks in README files

This commit is contained in:
Wes Gilleland
2018-03-28 01:35:43 -04:00
parent 6879990857
commit 86ee59c232
13 changed files with 49 additions and 45 deletions

View File

@ -31,7 +31,7 @@ Wikipedia says
Having said that let me add a bit about what telescoping constructor anti-pattern is. At one point or the other we have all seen a constructor like below:
```
```java
public Hero(Profession profession, String name, HairType hairType, HairColor hairColor, Armor armor, Weapon weapon) {
}
```
@ -42,7 +42,7 @@ As you can see the number of constructor parameters can quickly get out of hand
The sane alternative is to use the Builder pattern. First of all we have our hero that we want to create
```
```java
public final class Hero {
private final Profession profession;
private final String name;
@ -64,7 +64,7 @@ public final class Hero {
And then we have the builder
```
```java
public static class Builder {
private final Profession profession;
private final String name;
@ -109,7 +109,7 @@ And then we have the builder
And then it can be used as:
```
```java
Hero mage = new Hero.Builder(Profession.MAGE, "Riobard").withHairColor(HairColor.BLACK).withWeapon(Weapon.DAGGER).build();
```