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 PersonValidator { | |
public boolean validate(Person person) { | |
boolean valid = person != null; | |
if (valid) { | |
valid = person.getName() != null; | |
} | |
if (valid) { | |
valid = person.getEmail() != null; | |
} |
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
@RunWith(JunitSuiteRunner.class) | |
public class FizzBuzzFluentTest { | |
{ | |
describe("FizzBuzz game", it -> { | |
it.should("say Fizz", expect -> { | |
FizzBuzz fizzBuzz; | |
Given: | |
fizzBuzz = new FizzBuzz(3); |
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
# As it is a name used to identify clusters, use a name with uniqueness and a meaning. | |
cluster.name: ElasticSearch-cluster | |
# A node name is automatically created but it is recommended to use a name that is discernible in a cluster like a host name. | |
node.name: "Elasticsearch.my01" | |
# The default value of the following two is all true. node.master sets whether the node can be the master, while node.data is a configuration for whether it is a node to store data. Usually you need to set the two values as true, and if the size of a cluster is big, you should adjust this value by node to configure three types of node. More details will be explained in the account of topologies configuration later. | |
node.master: true | |
node.data: true | |
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
select | |
repository_language, | |
type, | |
count(distinct(repository_url)) as active_repos_by_url, | |
count(repository_language) as events, | |
YEAR(created_at) as year, | |
QUARTER(created_at) as quarter | |
from [githubarchive:github.timeline] | |
where | |
( |
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 void aboutMyDay() { | |
boolean isWakeUp = wakeUp(); | |
if( isWakeUp ) { | |
boolean isShower = shower(); | |
if( isShower ) { | |
boolean isClothe = putClothe(); | |
if( isClothe ) { | |
... | |
} | |
} |
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
if (x < 0) { | |
throw new Exception("ข้อมูลไม่สามารถติดลบได้นะ"); | |
} else { | |
System.out.println("แจ่ม ทำงานได้"); | |
} |
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 Money { | |
private int amount; | |
private String currency; | |
public Money(int amount, String currency) { | |
this.amount = amount; | |
this.currency = currency; | |
} | |
public int amount() { |
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 Money { | |
... | |
public Money add(Money money) { | |
return new Money(amount() + money.amount(), currency()); | |
} | |
... | |
} |
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
private static final String COMMA_DELIMITER = ","; | |
//แบบที่ 1 | |
String[] names = {"I", "love", "You"}; | |
System.out.println( String.join(COMMA_DELIMITER, names) ); | |
//แบบที่ 2 | |
System.out.println(String.join(COMMA_DELIMITER, "I", "love", "You")); |
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
evaluationDependsOn(":app") | |
apply plugin: 'java' | |
dependencies { | |
def androidModule = project(':app') | |
testCompile project(path: ':app', configuration: 'debugCompile') | |
def debugVariant = androidModule.android.applicationVariants.find({it.name == 'debug'}) |