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
// two-level functions; wrapper of the recursive one | |
private void Horners(double[] coeff, double x, int n) { | |
this.x = x; | |
this.coeff = coeff; | |
H(n); | |
} | |
private double H(int k) | |
{ | |
if (k == 0) { | |
return coeff[0]; |
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
INSERT_UPDATE MinConstraint;id[unique=true];severity(code,itemtype(code));active;annotation;descriptor(enclosingType(code),qualifier);message[lang=de];message[lang=en];value | |
;AlbumSalesMustNotBeNegative;ERROR:Severity;true;javax.validation.constraints.Min;Band:albumSales;Albumverkäufe dürfen nicht negativ sein;Album sales must not be negative;1 | |
INSERT_UPDATE NotLoremIpsumConstraint;id[unique=true];severity(code,itemtype(code));active;annotation;descriptor(enclosingType(code),qualifier);message[lang=de];message[lang=en] | |
;BandHistoryNotIpsum;ERROR:Severity;true;concerttours.constraints.NotLoremIpsum;Band:history;Band Geschichte sollte nicht Lorem ipsum Platzhalter Text.;Band history should not be Lorem ipsum placeholder text.; |
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
Optional.of(opt).map(value -> { System.out.println(value); | |
return value; }) | |
.orElseGet(() -> { System.out.println("not present"); | |
return -1;}); |
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
Optionals.ifPresentOrElse(opt, System.out::println, | |
() -> System.out.println("not present")); |
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
opt.ifPresentOrElse(System.out::println, | |
() -> System.out.println("not present")); |
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
opt.<Runnable>map(value -> () -> System.out.println("Found " + value)) | |
.orElse(() -> System.out.println("Not present!")) | |
.run(); |
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 Optional<StoreConfiguration> update(Store store, String value) { | |
return store.getConfigurationId() // Optional<UUID> | |
.flatMap(storeConfigurationRepository::findById) // Optional<StoreConfiguration> | |
.map(config -> this.updateStoreConfiguration(store,value)) // Optional<StoreConfiguration> | |
} |
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 StoreConfiguration updateConfig(Store store, String value) { | |
return store.getConfigurationId().map(configurationId ->{ | |
return storeConfigurationRepository.findById(configurationId).map(storeConfiguration -> { | |
return updateStoreConfiguration(storeConfiguration, value); | |
}).orElseThrow(); | |
}).orElseThrow(); | |
} |
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
getValue(x).orElse(getValue(y) | |
.orElseThrow(() -> new NotFoundException("value not present"))); | |
public Optional<Value> getValue(Source s) | |
{ | |
System.out.println("Source: " + s.getName()); | |
// returns value from s source | |
} |
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
getValue(x).orElseGet(() -> getValue(y) | |
.orElseThrow(() -> new NotFoundException("value not present"))); | |
public Optional<Value> getValue(Source s) | |
{ | |
System.out.println("Source: " + s.getName()); | |
// returns value from s source | |
} |