This file contains hidden or 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
private boolean isRed(String color) { | |
return color.equals("RED"); | |
} |
This file contains hidden or 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
private boolean isRed(String color) { | |
return "RED".equals(color); | |
} |
This file contains hidden or 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
static class Customer { | |
private final String firstName; | |
private final String surname; | |
private final Optional<Integer> age; | |
private final Optional<String> address; | |
private final Optional<String> phoneNumber; | |
private final Optional<Sex> sex; | |
public Customer(String firstName, String surname, Optional<Integer> age, Optional<String> address, Optional<String> phoneNumber, Optional<Sex> sex) { |
This file contains hidden or 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
final Customer customer = new Customer( | |
"John", | |
"Smith", | |
Optional.empty(), | |
Optional.empty(), | |
Optional.empty(), | |
Optional.empty() | |
); |
This file contains hidden or 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
final Customer testCustomer = new Customer( | |
"John", | |
"Smith", | |
Optional.of(30), | |
Optional.of("Flat 0, Some Street, W1 XYZ"), | |
Optional.of("01234 567890"), | |
Optional.of(Sex.MALE) | |
); |
This file contains hidden or 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
import java.util.Optional; | |
public class Customer { | |
private final String firstName; | |
private final String surname; | |
private final Integer age; | |
private final String address; | |
private final String phoneNumber; | |
private final Sex sex; |
This file contains hidden or 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
final Customer customer = Customer.builderOf("John", "Smith") | |
.withAge(30) | |
.build(); | |
System.out.println(customer.getAddress().orElse("No address present")); |
This file contains hidden or 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
@Test | |
public void convert_shouldReturnI() { | |
final String romanNumeral = RomanNumerals.convert(1); | |
assertThat(romanNumeral, is("I")); | |
} |
This file contains hidden or 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
@Test | |
public void convert_shouldReturnI() { | |
final String romanNumeral = RomanNumerals.convert(1); | |
assertThat(romanNumeral, is("I")); | |
} |
This file contains hidden or 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 RomanNumerals { | |
public static String convert(int number) { | |
return ""; | |
} | |
} |
OlderNewer