SlideShare a Scribd company logo
Lombok
2017-07-20
onozaty
Lombok?
• Java (
)
•
• getter/setter
• equals, hashCode
• toString
•
Lombok?
•
@Getter
@Setter
public class Customer {
private int id;
private String name;
}
public class Customer {
private int id;
private String name;
public int getId() {
return this.id;
}
public String getName() {
return this.name;
}
public void setId(final int id) {
this.id = id;
}
public void setName(final String name) {
this.name = name;
}
}
Lombok?
• IDE IDE
• Lombok
( )
• IDE
• Eclipse Lombok jar
Eclipse
( )
@Getter, @Setter
• getter/setter
• (
)
• (
public)
• final setter (
)
@Getter, @Setter
public class GetterSetterExample {
//
@Getter
@Setter
private int id;
//
@Setter(AccessLevel.PROTECTED)
private String name;
}
public class GetterSetterExample {
private int id;
private String name;
public int getId() {
return this.id;
}
public void setId(final int id) {
this.id = id;
}
protected void setName(final String name) {
this.name = name;
}
}
@ToString
•
toString
•
@ToString
@ToString
public class ToStringExample {
private int id;
private String name;
public String getName() {
return name;
}
}
// exclude
@ToString(exclude = "name")
class ToStringExample2 {
private int id;
private String name;
}
public class ToStringExample {
private int id;
private String name;
public String getName() {
return name;
}
@Override
public String toString() {
return "ToStringExample(id=" + this.id
+ ", name=" + this.getName() + ")";
}
}
class ToStringExample2 {
private int id;
private String name;
@Override
public String toString() {
return "ToStringExample2(id="
+ this.id + ")";
}
}
@EqualsAndHashCode
• equals hashCode
•
•
Lombok
@EqualsAndHashCode
@EqualsAndHashCode
public class EqualsAndHashCodeExample
{
private int id;
private String name;
}
//
@EqualsAndHashCode(exclude = "age")
class EqualsAndHashCodeExample2 {
private int id;
private String name;
private int age;
}
public class EqualsAndHashCodeExample {
private int id;
private String name;
@Override
public boolean equals(final Object o) { … }
@Override
public int hashCode() { … }
}
public class EqualsAndHashCodeExample2 {
private int id;
private String name;
private int age;
// age
@Override
public boolean equals(final Object o) { … }
@Override
public int hashCode() { … }
}
@AllArgsConstructor,
@NoArgsConstructor,
@RequiredArgsConstructor
•
• @AllArgsConstructor
• @NoArgsConstructor
• @RequiredArgsConstructor final
(final
)
@AllArgsConstructor,
@NoArgsConstructor,
@RequiredArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
public class ConstructorExample {
private int id;
private String name;
}
@RequiredArgsConstructor
class ConstructorExample2 {
private final int id;
private String name;
}
public class ConstructorExample {
private int id;
private String name;
public ConstructorExample(
final int id, final String name) {
this.id = id;
this.name = name;
}
public ConstructorExample() {
}
}
class ConstructorExample2 {
private final int id;
private String name;
public ConstructorExample2(final int id) {
this.id = id;
}
}
@Data
•
• @ToString
• @EqualsAndHashCode
• @Getter
• @Setter
• @RequiredArgsConstructor
•
@Data
@Data
public class DataExample {
private final int id;
private String name;
}
public class DataExample {
private final int id;
private String name;
public DataExample(final int id) {
this.id = id;
}
public int getId() {
return this.id;
}
public String getName() {
return this.name;
}
public void setName(final String name) {
this.name = name;
}
@Override
public boolean equals(final Object o) { … }
@Override
public int hashCode() { … }
@Override
public String toString() { … }
}
@Value
• final
• @ToString
• @EqualsAndHashCode
• @Getter
• @RequiredArgsConstructor
• Immutable
@Value
@Value
public class ValueExample {
private int id;
private String name;
}
public final class ValueExample {
private final int id;
private final String name;
public ValueExample(
final int id, final String name) {
this.id = id;
this.name = name;
}
public int getId() {
return this.id;
}
public String getName() {
return this.name;
}
@Override
public boolean equals(final Object o) { … }
@Override
public int hashCode() { … }
@Override
public String toString() { … }
}
@Builder
• Builder (GoF Effective
Java ) Builder
• Builder
@Builder
public static void main(String[] args) {
// Builder ( )
Customer customer = new Customer(
"Taro",
"Yamada",
"Tokyo",
Arrays.asList("A", "B"));
System.out.println(customer);
}
@AllArgsConstructor
@ToString
class Customer {
private String firstName;
private String lastName;
private String city;
private List<String> tags;
}
public static void main(String[] args) {
// Builder
Customer customer = Customer.builder()
.firstName("Taro")
.lastName("Yamada")
.city("Tokyo")
.tag("A")
.tag("B")
.build();
System.out.println(customer);
}
@Builder
@ToString
class Customer {
private String firstName;
private String lastName;
private String city;
@Singular
private List<String> tags;
}
@Slf4j
• log static Logger
• Slf4j Apache commons log(@Log)
• Logger
@Slf4j
@Slf4j
public class LogExample {
public static void main(String[] args) {
log.info("main.");
}
}
public class LogExample {
private static final org.slf4j.Logger log =
org.slf4j.LoggerFactory.getLogger(LogExample.class);
public static void main(String[] args) {
log.info("main.");
}
}
@NonNull
• null
(null
NullPointerException )
• Objects.requireNonNull
@NonNull
@RequiredArgsConstructor
public class NonNullExample {
@NonNull
private String name;
public void printLength(
@NonNull String message) {
System.out.println(
message.length());
}
}
public class NonNullExample {
@NonNull
private String name;
public void printLength(
@NonNull String message) {
if (message == null) {
throw new NullPointerException("message");
}
System.out.println(message.length());
}
public NonNullExample(
@NonNull final String name) {
if (name == null) {
throw new NullPointerException("name");
}
this.name = name;
}
}
val
•
• Scala val
val
public static void main(String[] args) {
val list = new ArrayList<String>();
list.add("a");
list.add("b");
val item = list.get(0);
System.out.println(item);
}
public static void main(String[] args) {
final ArrayList<String> list =
new ArrayList<String>();
list.add("a");
list.add("b");
final String item = list.get(0);
System.out.println(item);
}
@Cleanup
•
( )
close
• try/finally
• close
@Cleanup
public static void main(String[] args) throws IOException {
Path filePath = Paths.get(args[0]);
@Cleanup BufferedReader reader = Files.newBufferedReader(filePath);
System.out.println(reader.readLine());
}
public static void main(String[] args) throws IOException {
Path filePath = Paths.get(args[0]);
BufferedReader reader = Files.newBufferedReader(filePath);
try {
System.out.println(reader.readLine());
} finally {
if (Collections.singletonList(reader).get(0) != null) {
reader.close();
}
}
}
@Synchronized
• synchronized
• static
Lock
• Lock
@Synchronized
public class SynchronizedExample {
@Synchronized
public static void hello() {
System.out.println("hello");
}
@Synchronized
public void bye() {
System.out.println("bye");
}
}
public class SynchronizedExample {
private static final Object $LOCK = new Object[0];
private final Object $lock = new Object[0];
public static void hello() {
synchronized (SynchronizedExample.$LOCK) {
System.out.println("hello");
}
}
public void bye() {
synchronized (this.$lock) {
System.out.println("bye");
}
}
}
@SneakyThrows
• (
)
•
•
• https://github.com/rzwitserloot/lombok/blob/master/src/core/
lombok/Lombok.java#L49
• Lombok
Lombok jar
@SneakyThrows
public class SneakyThrowsExample {
@SneakyThrows
public static void main(String[] args) {
throw new Exception();
}
}
public class SneakyThrowsExample {
public static void main(String[] args) {
try {
throw new Exception();
} catch (final Throwable $ex) {
throw Lombok.sneakyThrow($ex);
}
}
}
delombok
• delombok Lombok
• delombok
• https://projectlombok.org/features/delombok
> java -jar lombok.jar delombok src -d src-delomboked
• Lombok
onMethd onParam
• https://projectlombok.org/features/experimental/onX
Lombok
•
•
• getter/setter
•
• equals hashCode
Lombok
•
• Lombok
• Lombok
Lombok
• val @Cleanup @SneakyThrows
(Lombok
)
•
Lombok
• https://projectlombok.org/features/all

More Related Content

What's hot

Basic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIBasic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time API
jagriti srivastava
 
Excuse me, sir, do you have a moment to talk about tests in Kotlin
Excuse me, sir, do you have a moment to talk about tests in KotlinExcuse me, sir, do you have a moment to talk about tests in Kotlin
Excuse me, sir, do you have a moment to talk about tests in Kotlin
leonsabr
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
MuhammadTalha436
 
Java Programming - 06 java file io
Java Programming - 06 java file ioJava Programming - 06 java file io
Java Programming - 06 java file io
Danairat Thanabodithammachari
 
Introduction To Csharp
Introduction To CsharpIntroduction To Csharp
Introduction To Csharpg_hemanth17
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpsinghadarsh
 
Introduction to CSharp
Introduction to CSharpIntroduction to CSharp
Introduction to CSharpMody Farouk
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpRaga Vahini
 
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.
Nishan Barot
 
Using Xcore with Xtext
Using Xcore with XtextUsing Xcore with Xtext
Using Xcore with Xtext
Holger Schill
 
Java and XML Schema
Java and XML SchemaJava and XML Schema
Java and XML Schema
Raji Ghawi
 
C# 7.0 Hacks and Features
C# 7.0 Hacks and FeaturesC# 7.0 Hacks and Features
C# 7.0 Hacks and Features
Abhishek Sur
 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
Ganesh Samarthyam
 
Swift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CSwift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-C
Alexis Gallagher
 
4java Basic Syntax
4java Basic Syntax4java Basic Syntax
4java Basic SyntaxAdil Jafri
 
Modul Praktek Java OOP
Modul Praktek Java OOP Modul Praktek Java OOP
Modul Praktek Java OOP
Zaenal Arifin
 

What's hot (18)

Basic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIBasic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time API
 
Excuse me, sir, do you have a moment to talk about tests in Kotlin
Excuse me, sir, do you have a moment to talk about tests in KotlinExcuse me, sir, do you have a moment to talk about tests in Kotlin
Excuse me, sir, do you have a moment to talk about tests in Kotlin
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 
Java Programming - 06 java file io
Java Programming - 06 java file ioJava Programming - 06 java file io
Java Programming - 06 java file io
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
Introduction To Csharp
Introduction To CsharpIntroduction To Csharp
Introduction To Csharp
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Introduction to CSharp
Introduction to CSharpIntroduction to CSharp
Introduction to CSharp
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.
 
Using Xcore with Xtext
Using Xcore with XtextUsing Xcore with Xtext
Using Xcore with Xtext
 
Java and XML Schema
Java and XML SchemaJava and XML Schema
Java and XML Schema
 
C# 7.0 Hacks and Features
C# 7.0 Hacks and FeaturesC# 7.0 Hacks and Features
C# 7.0 Hacks and Features
 
Java Concurrency by Example
Java Concurrency by ExampleJava Concurrency by Example
Java Concurrency by Example
 
Swift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CSwift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-C
 
4java Basic Syntax
4java Basic Syntax4java Basic Syntax
4java Basic Syntax
 
Java practical
Java practicalJava practical
Java practical
 
Modul Praktek Java OOP
Modul Praktek Java OOP Modul Praktek Java OOP
Modul Praktek Java OOP
 

Similar to Lombokの紹介

3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java
DEVTYPE
 
Creating a Facebook Clone - Part XIX.pdf
Creating a Facebook Clone - Part XIX.pdfCreating a Facebook Clone - Part XIX.pdf
Creating a Facebook Clone - Part XIX.pdf
ShaiAlmog1
 
A evolução da persistência de dados (com sqlite) no android
A evolução da persistência de dados (com sqlite) no androidA evolução da persistência de dados (com sqlite) no android
A evolução da persistência de dados (com sqlite) no android
Rodrigo de Souza Castro
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokusHamletDRC
 
Dev Day Andreas Roth.pdf
Dev Day Andreas Roth.pdfDev Day Andreas Roth.pdf
Dev Day Andreas Roth.pdf
CarolinaMatthies
 
OOP Lab Report.docx
OOP Lab Report.docxOOP Lab Report.docx
OOP Lab Report.docx
ArafatSahinAfridi
 
Android Architecure Components - introduction
Android Architecure Components - introductionAndroid Architecure Components - introduction
Android Architecure Components - introduction
Paulina Szklarska
 
Creating a Facebook Clone - Part XX.pdf
Creating a Facebook Clone - Part XX.pdfCreating a Facebook Clone - Part XX.pdf
Creating a Facebook Clone - Part XX.pdf
ShaiAlmog1
 
Kotlin Data Model
Kotlin Data ModelKotlin Data Model
Kotlin Data Model
Kros Huang
 
[2019] PAYCO 매거진 서버 Kotlin 적용기
[2019] PAYCO 매거진 서버 Kotlin 적용기[2019] PAYCO 매거진 서버 Kotlin 적용기
[2019] PAYCO 매거진 서버 Kotlin 적용기
NHN FORWARD
 
Java2
Java2Java2
Domänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit XtextDomänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit Xtext
Dr. Jan Köhnlein
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
ShaiAlmog1
 
Architecure components by Paulina Szklarska
Architecure components by Paulina SzklarskaArchitecure components by Paulina Szklarska
Architecure components by Paulina Szklarska
Women in Technology Poland
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodecamp Romania
 
14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining Classes
Intro C# Book
 
NOSQL part of the SpringOne 2GX 2010 keynote
NOSQL part of the SpringOne 2GX 2010 keynoteNOSQL part of the SpringOne 2GX 2010 keynote
NOSQL part of the SpringOne 2GX 2010 keynoteEmil Eifrem
 
Creating a Facebook Clone - Part XIX - Transcript.pdf
Creating a Facebook Clone - Part XIX - Transcript.pdfCreating a Facebook Clone - Part XIX - Transcript.pdf
Creating a Facebook Clone - Part XIX - Transcript.pdf
ShaiAlmog1
 
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdfplease navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
aioils
 
Green dao 3.0
Green dao 3.0Green dao 3.0
Green dao 3.0
彥彬 洪
 

Similar to Lombokの紹介 (20)

3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java
 
Creating a Facebook Clone - Part XIX.pdf
Creating a Facebook Clone - Part XIX.pdfCreating a Facebook Clone - Part XIX.pdf
Creating a Facebook Clone - Part XIX.pdf
 
A evolução da persistência de dados (com sqlite) no android
A evolução da persistência de dados (com sqlite) no androidA evolução da persistência de dados (com sqlite) no android
A evolução da persistência de dados (com sqlite) no android
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
 
Dev Day Andreas Roth.pdf
Dev Day Andreas Roth.pdfDev Day Andreas Roth.pdf
Dev Day Andreas Roth.pdf
 
OOP Lab Report.docx
OOP Lab Report.docxOOP Lab Report.docx
OOP Lab Report.docx
 
Android Architecure Components - introduction
Android Architecure Components - introductionAndroid Architecure Components - introduction
Android Architecure Components - introduction
 
Creating a Facebook Clone - Part XX.pdf
Creating a Facebook Clone - Part XX.pdfCreating a Facebook Clone - Part XX.pdf
Creating a Facebook Clone - Part XX.pdf
 
Kotlin Data Model
Kotlin Data ModelKotlin Data Model
Kotlin Data Model
 
[2019] PAYCO 매거진 서버 Kotlin 적용기
[2019] PAYCO 매거진 서버 Kotlin 적용기[2019] PAYCO 매거진 서버 Kotlin 적용기
[2019] PAYCO 매거진 서버 Kotlin 적용기
 
Java2
Java2Java2
Java2
 
Domänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit XtextDomänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit Xtext
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
 
Architecure components by Paulina Szklarska
Architecure components by Paulina SzklarskaArchitecure components by Paulina Szklarska
Architecure components by Paulina Szklarska
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
 
14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining Classes
 
NOSQL part of the SpringOne 2GX 2010 keynote
NOSQL part of the SpringOne 2GX 2010 keynoteNOSQL part of the SpringOne 2GX 2010 keynote
NOSQL part of the SpringOne 2GX 2010 keynote
 
Creating a Facebook Clone - Part XIX - Transcript.pdf
Creating a Facebook Clone - Part XIX - Transcript.pdfCreating a Facebook Clone - Part XIX - Transcript.pdf
Creating a Facebook Clone - Part XIX - Transcript.pdf
 
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdfplease navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
 
Green dao 3.0
Green dao 3.0Green dao 3.0
Green dao 3.0
 

More from onozaty

情報を表現するときのポイント
情報を表現するときのポイント情報を表現するときのポイント
情報を表現するときのポイント
onozaty
 
チームで開発するための環境を整える
チームで開発するための環境を整えるチームで開発するための環境を整える
チームで開発するための環境を整える
onozaty
 
Selenium入門(2023年版)
Selenium入門(2023年版)Selenium入門(2023年版)
Selenium入門(2023年版)
onozaty
 
40歳過ぎてもエンジニアでいるためにやっていること
40歳過ぎてもエンジニアでいるためにやっていること40歳過ぎてもエンジニアでいるためにやっていること
40歳過ぎてもエンジニアでいるためにやっていること
onozaty
 
Java8から17へ
Java8から17へJava8から17へ
Java8から17へ
onozaty
 
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -
onozaty
 
Redmine issue assign notice plugin の紹介
Redmine issue assign notice plugin の紹介Redmine issue assign notice plugin の紹介
Redmine issue assign notice plugin の紹介
onozaty
 
最近作ったもの
最近作ったもの最近作ったもの
最近作ったもの
onozaty
 
Selenium入門
Selenium入門Selenium入門
Selenium入門
onozaty
 
Redmineの画面をあなた好みにカスタマイズ - View customize pluginの紹介 - Redmine Japan 2020
Redmineの画面をあなた好みにカスタマイズ - View customize pluginの紹介 - Redmine Japan 2020Redmineの画面をあなた好みにカスタマイズ - View customize pluginの紹介 - Redmine Japan 2020
Redmineの画面をあなた好みにカスタマイズ - View customize pluginの紹介 - Redmine Japan 2020
onozaty
 
「伝わるチケット」の書き方
「伝わるチケット」の書き方「伝わるチケット」の書き方
「伝わるチケット」の書き方
onozaty
 
View customize plugin for Redmineの紹介 (2019年版)
View customize plugin for Redmineの紹介 (2019年版)View customize plugin for Redmineの紹介 (2019年版)
View customize plugin for Redmineの紹介 (2019年版)
onozaty
 
View customize1.2.0の紹介
View customize1.2.0の紹介View customize1.2.0の紹介
View customize1.2.0の紹介
onozaty
 
WebSocketでカメラの映像を共有してみた
WebSocketでカメラの映像を共有してみたWebSocketでカメラの映像を共有してみた
WebSocketでカメラの映像を共有してみた
onozaty
 
Spring Bootを触ってみた
Spring Bootを触ってみたSpring Bootを触ってみた
Spring Bootを触ってみた
onozaty
 
30歳過ぎてもエンジニアでいるためにやったこと
30歳過ぎてもエンジニアでいるためにやったこと30歳過ぎてもエンジニアでいるためにやったこと
30歳過ぎてもエンジニアでいるためにやったこと
onozaty
 
View customize pluginを使いこなす
View customize pluginを使いこなすView customize pluginを使いこなす
View customize pluginを使いこなす
onozaty
 
View Customize Pluginで出来ること
View Customize Pluginで出来ることView Customize Pluginで出来ること
View Customize Pluginで出来ること
onozaty
 
技術書のススメ
技術書のススメ技術書のススメ
技術書のススメ
onozaty
 
課題管理と情報共有のためのツール群
課題管理と情報共有のためのツール群課題管理と情報共有のためのツール群
課題管理と情報共有のためのツール群
onozaty
 

More from onozaty (20)

情報を表現するときのポイント
情報を表現するときのポイント情報を表現するときのポイント
情報を表現するときのポイント
 
チームで開発するための環境を整える
チームで開発するための環境を整えるチームで開発するための環境を整える
チームで開発するための環境を整える
 
Selenium入門(2023年版)
Selenium入門(2023年版)Selenium入門(2023年版)
Selenium入門(2023年版)
 
40歳過ぎてもエンジニアでいるためにやっていること
40歳過ぎてもエンジニアでいるためにやっていること40歳過ぎてもエンジニアでいるためにやっていること
40歳過ぎてもエンジニアでいるためにやっていること
 
Java8から17へ
Java8から17へJava8から17へ
Java8から17へ
 
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -
今からでも遅くないDBマイグレーション - Flyway と SchemaSpy の紹介 -
 
Redmine issue assign notice plugin の紹介
Redmine issue assign notice plugin の紹介Redmine issue assign notice plugin の紹介
Redmine issue assign notice plugin の紹介
 
最近作ったもの
最近作ったもの最近作ったもの
最近作ったもの
 
Selenium入門
Selenium入門Selenium入門
Selenium入門
 
Redmineの画面をあなた好みにカスタマイズ - View customize pluginの紹介 - Redmine Japan 2020
Redmineの画面をあなた好みにカスタマイズ - View customize pluginの紹介 - Redmine Japan 2020Redmineの画面をあなた好みにカスタマイズ - View customize pluginの紹介 - Redmine Japan 2020
Redmineの画面をあなた好みにカスタマイズ - View customize pluginの紹介 - Redmine Japan 2020
 
「伝わるチケット」の書き方
「伝わるチケット」の書き方「伝わるチケット」の書き方
「伝わるチケット」の書き方
 
View customize plugin for Redmineの紹介 (2019年版)
View customize plugin for Redmineの紹介 (2019年版)View customize plugin for Redmineの紹介 (2019年版)
View customize plugin for Redmineの紹介 (2019年版)
 
View customize1.2.0の紹介
View customize1.2.0の紹介View customize1.2.0の紹介
View customize1.2.0の紹介
 
WebSocketでカメラの映像を共有してみた
WebSocketでカメラの映像を共有してみたWebSocketでカメラの映像を共有してみた
WebSocketでカメラの映像を共有してみた
 
Spring Bootを触ってみた
Spring Bootを触ってみたSpring Bootを触ってみた
Spring Bootを触ってみた
 
30歳過ぎてもエンジニアでいるためにやったこと
30歳過ぎてもエンジニアでいるためにやったこと30歳過ぎてもエンジニアでいるためにやったこと
30歳過ぎてもエンジニアでいるためにやったこと
 
View customize pluginを使いこなす
View customize pluginを使いこなすView customize pluginを使いこなす
View customize pluginを使いこなす
 
View Customize Pluginで出来ること
View Customize Pluginで出来ることView Customize Pluginで出来ること
View Customize Pluginで出来ること
 
技術書のススメ
技術書のススメ技術書のススメ
技術書のススメ
 
課題管理と情報共有のためのツール群
課題管理と情報共有のためのツール群課題管理と情報共有のためのツール群
課題管理と情報共有のためのツール群
 

Recently uploaded

Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Yara Milbes
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 

Recently uploaded (20)

Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 

Lombokの紹介

  • 2. Lombok? • Java ( ) • • getter/setter • equals, hashCode • toString •
  • 3. Lombok? • @Getter @Setter public class Customer { private int id; private String name; } public class Customer { private int id; private String name; public int getId() { return this.id; } public String getName() { return this.name; } public void setId(final int id) { this.id = id; } public void setName(final String name) { this.name = name; } }
  • 5. • Lombok ( ) • IDE • Eclipse Lombok jar Eclipse ( )
  • 6. @Getter, @Setter • getter/setter • ( ) • ( public) • final setter ( )
  • 7. @Getter, @Setter public class GetterSetterExample { // @Getter @Setter private int id; // @Setter(AccessLevel.PROTECTED) private String name; } public class GetterSetterExample { private int id; private String name; public int getId() { return this.id; } public void setId(final int id) { this.id = id; } protected void setName(final String name) { this.name = name; } }
  • 9. @ToString @ToString public class ToStringExample { private int id; private String name; public String getName() { return name; } } // exclude @ToString(exclude = "name") class ToStringExample2 { private int id; private String name; } public class ToStringExample { private int id; private String name; public String getName() { return name; } @Override public String toString() { return "ToStringExample(id=" + this.id + ", name=" + this.getName() + ")"; } } class ToStringExample2 { private int id; private String name; @Override public String toString() { return "ToStringExample2(id=" + this.id + ")"; } }
  • 11. @EqualsAndHashCode @EqualsAndHashCode public class EqualsAndHashCodeExample { private int id; private String name; } // @EqualsAndHashCode(exclude = "age") class EqualsAndHashCodeExample2 { private int id; private String name; private int age; } public class EqualsAndHashCodeExample { private int id; private String name; @Override public boolean equals(final Object o) { … } @Override public int hashCode() { … } } public class EqualsAndHashCodeExample2 { private int id; private String name; private int age; // age @Override public boolean equals(final Object o) { … } @Override public int hashCode() { … } }
  • 13. @AllArgsConstructor, @NoArgsConstructor, @RequiredArgsConstructor @AllArgsConstructor @NoArgsConstructor public class ConstructorExample { private int id; private String name; } @RequiredArgsConstructor class ConstructorExample2 { private final int id; private String name; } public class ConstructorExample { private int id; private String name; public ConstructorExample( final int id, final String name) { this.id = id; this.name = name; } public ConstructorExample() { } } class ConstructorExample2 { private final int id; private String name; public ConstructorExample2(final int id) { this.id = id; } }
  • 14. @Data • • @ToString • @EqualsAndHashCode • @Getter • @Setter • @RequiredArgsConstructor •
  • 15. @Data @Data public class DataExample { private final int id; private String name; } public class DataExample { private final int id; private String name; public DataExample(final int id) { this.id = id; } public int getId() { return this.id; } public String getName() { return this.name; } public void setName(final String name) { this.name = name; } @Override public boolean equals(final Object o) { … } @Override public int hashCode() { … } @Override public String toString() { … } }
  • 16. @Value • final • @ToString • @EqualsAndHashCode • @Getter • @RequiredArgsConstructor • Immutable
  • 17. @Value @Value public class ValueExample { private int id; private String name; } public final class ValueExample { private final int id; private final String name; public ValueExample( final int id, final String name) { this.id = id; this.name = name; } public int getId() { return this.id; } public String getName() { return this.name; } @Override public boolean equals(final Object o) { … } @Override public int hashCode() { … } @Override public String toString() { … } }
  • 18. @Builder • Builder (GoF Effective Java ) Builder • Builder
  • 19. @Builder public static void main(String[] args) { // Builder ( ) Customer customer = new Customer( "Taro", "Yamada", "Tokyo", Arrays.asList("A", "B")); System.out.println(customer); } @AllArgsConstructor @ToString class Customer { private String firstName; private String lastName; private String city; private List<String> tags; } public static void main(String[] args) { // Builder Customer customer = Customer.builder() .firstName("Taro") .lastName("Yamada") .city("Tokyo") .tag("A") .tag("B") .build(); System.out.println(customer); } @Builder @ToString class Customer { private String firstName; private String lastName; private String city; @Singular private List<String> tags; }
  • 20. @Slf4j • log static Logger • Slf4j Apache commons log(@Log) • Logger
  • 21. @Slf4j @Slf4j public class LogExample { public static void main(String[] args) { log.info("main."); } } public class LogExample { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogExample.class); public static void main(String[] args) { log.info("main."); } }
  • 23. @NonNull @RequiredArgsConstructor public class NonNullExample { @NonNull private String name; public void printLength( @NonNull String message) { System.out.println( message.length()); } } public class NonNullExample { @NonNull private String name; public void printLength( @NonNull String message) { if (message == null) { throw new NullPointerException("message"); } System.out.println(message.length()); } public NonNullExample( @NonNull final String name) { if (name == null) { throw new NullPointerException("name"); } this.name = name; } }
  • 25. val public static void main(String[] args) { val list = new ArrayList<String>(); list.add("a"); list.add("b"); val item = list.get(0); System.out.println(item); } public static void main(String[] args) { final ArrayList<String> list = new ArrayList<String>(); list.add("a"); list.add("b"); final String item = list.get(0); System.out.println(item); }
  • 27. @Cleanup public static void main(String[] args) throws IOException { Path filePath = Paths.get(args[0]); @Cleanup BufferedReader reader = Files.newBufferedReader(filePath); System.out.println(reader.readLine()); } public static void main(String[] args) throws IOException { Path filePath = Paths.get(args[0]); BufferedReader reader = Files.newBufferedReader(filePath); try { System.out.println(reader.readLine()); } finally { if (Collections.singletonList(reader).get(0) != null) { reader.close(); } } }
  • 29. @Synchronized public class SynchronizedExample { @Synchronized public static void hello() { System.out.println("hello"); } @Synchronized public void bye() { System.out.println("bye"); } } public class SynchronizedExample { private static final Object $LOCK = new Object[0]; private final Object $lock = new Object[0]; public static void hello() { synchronized (SynchronizedExample.$LOCK) { System.out.println("hello"); } } public void bye() { synchronized (this.$lock) { System.out.println("bye"); } } }
  • 31. @SneakyThrows public class SneakyThrowsExample { @SneakyThrows public static void main(String[] args) { throw new Exception(); } } public class SneakyThrowsExample { public static void main(String[] args) { try { throw new Exception(); } catch (final Throwable $ex) { throw Lombok.sneakyThrow($ex); } } }
  • 32. delombok • delombok Lombok • delombok • https://projectlombok.org/features/delombok > java -jar lombok.jar delombok src -d src-delomboked
  • 33. • Lombok onMethd onParam • https://projectlombok.org/features/experimental/onX
  • 35. Lombok • • Lombok • Lombok Lombok • val @Cleanup @SneakyThrows (Lombok )